简体   繁体   English

安装quantlib-python并在Linux中的jupyter中使用它

[英]Install quantlib-python and use it in jupyter in Linux

I am following Luigi Ballabio's "quantlib python cookbook" and it uses jupyter notebook as the playground for examples. 我正在关注Luigi Ballabio的“quantlib python cookbook”,它使用jupyter笔记本作为游乐场的例子。

The very first question is, I didn't know how to install quantlib-python in the jupyter notebook environment thus unable to get started. 第一个问题是,我不知道如何在jupyter笔记本环境中安装quantlib-python,因此无法启动。

Well I can first launch anaconda and whip out jupyter notebook from its dashboard, but a simple: 好吧,我可以先从仪表板上启动anaconda并甩掉jupyter笔记本,但这很简单:

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. 从运行“conda list”开始,我注意到在conda的默认python包装中没有任何与quantlib有关的内容。

Fine. 精细。 From this link: https://anaconda.org/domosute/quantlib , I managed to have it installed and "conda list" shows: 从这个链接: https//anaconda.org/domosute/quantlib ,我设法安装它,“conda list”显示:

quantlib                  1.15                          0   domosute
quantlib-python           1.15                     pypi_0    pypi

Then I restarted anaconda -> jupyter notebook, still complaining no quantlib found. 然后我重新启动了anaconda - > jupyter笔记本,仍抱怨没有找到quantlib。

What's more should I do so that I can start using quantlib in jupyter notebook. 我还应该这样做,以便我可以在jupyter笔记本中开始使用quantlib。

I am using 64bit ubuntu 18.04 我使用64位ubuntu 18.04

After some readings online, I found that I missed a step of quantlib-python binding. 经过一些在线阅读后,我发现我错过了一个quantlib-python绑定步骤。 To implement this, a tool called swig is used. 为了实现这一点,使用了一个名为swig的工具。 For ubuntu (which I use), it can be installed by "apt-get install swig". 对于ubuntu(我使用),它可以通过“apt-get install swig”安装。

Then the quantlib-swig needs to be installed. 然后需要安装quantlib-swig

Navigate into the quantlib-swig directory, if you have boost, quantlib installed and in their default directories, you can simply run: 导航到quantlib-swig目录,如果你安装了boost,quantlib并且在他们的默认目录中,你可以简单地运行:

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: 在此之后,你可以掏出“jupyter notebook”并开始测试一些quantlib代码:

在此输入图像描述

Reference: 参考:

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM