QuantLib in Python - cannot pickle 'SwigPyObject' object

3.2k views Asked by At

I complied QuantLib in Visual Studio 2017 and built the library under Release x64. Then I installed QuantLib Swig according to the instruction here: https://www.quantlib.org/install/windows-python.shtml

The directories in VS are set as in the screenshot: enter image description here

Then I tested a plain vanilla European option using QuantLib which ran without error:

option = EuropeanOption(PlainVanillaPayoff(Option.Call,100),EuropeanExercise(Date(11,5,2021)))

However I cannot check the variable option in the IDE (I use Spyder) and saw error:

Spyder was unable to retrieve the value of this variable from the console.

The error message was:

cannot pickle 'SwigPyObject' object

I see the value of this variable is EuropeanOption object of QuantLib.QuantLib module.

Version:

Python: 3.8
Quantlib: 1.19
QuantLib-SWIG: 1.19
boost: 1_74_0
Spyder: 4.1.4

Would very much appreciate any help.

1

There are 1 answers

2
Carlos Cordoba On BEST ANSWER

(Spyder maintainer here) Unfortunately not all Python objects can be explored through the Variable explorer. Only those that are picklable can be viewed, and the error message you posted above says EuropeanOption is not.

Furthermore, there's no workaround to avoid this issue because being picklable is a basic property of Python objects, and can't be changed by Spyder.