I am following Luigi Ballabio's "quantlib python cookbook" and it uses jupyter notebook as the playground for examples.
The very first question is, I didn't know how to install quantlib-python in the jupyter notebook environment thus unable to get started.
Well I can first launch anaconda and whip out jupyter notebook from its dashboard, but a simple:
import quantlib as ql
failed with this message.
ModuleNotFoundError: No module named 'quantlib'
From running "conda list" I noticed that nothing relating to quantlib exists in conda's default shipment of python packages.
Fine. From this link: https://anaconda.org/domosute/quantlib , I managed to have it installed and "conda list" shows:
quantlib 1.15 0 domosute
quantlib-python 1.15 pypi_0 pypi
Then I restarted anaconda -> jupyter notebook, still complaining no quantlib found.
What's more should I do so that I can start using quantlib in jupyter notebook.
I am using 64bit ubuntu 18.04
After some readings online, I found that I missed a step of quantlib-python binding. To implement this, a tool called swig is used. For ubuntu (which I use), it can be installed by "apt-get install swig".
Then the quantlib-swig needs to be installed.
Navigate into the quantlib-swig directory, if you have boost, quantlib installed and in their default directories, you can simply run:
python setup.py wrap
python setup.py build
python setup.py install
And test it:
python setup.py test
After which time, you can whip out "jupyter notebook" and start testing some quantlib code now:
Reference:
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.