在 Linux 中安装 quantlib-python 并在 jupyter 中使用它
Install quantlib-python and use it in jupyter in Linux
我正在关注 Luigi Ballabio 的 "quantlib python cookbook",它使用 jupyter notebook 作为示例。
第一个问题是,我不知道如何在jupyter notebook环境下安装quantlib-python,无法启动
好吧,我可以先启动 anaconda 并从它的仪表板中取出 jupyter notebook,但是一个简单的:
import quantlib as ql
此消息失败。
ModuleNotFoundError: No module named 'quantlib'
来自 运行 "conda list" 我注意到在 conda 默认发货的 python 包中不存在任何与 quantlib 相关的内容。
很好。从这个 link:https://anaconda.org/domosute/quantlib,我设法安装了它并且 "conda list" 显示:
quantlib 1.15 0 domosute
quantlib-python 1.15 pypi_0 pypi
然后我重启了anaconda -> jupyter notebook,仍然抱怨找不到quantlib。
我还应该做些什么才能开始在 jupyter notebook 中使用 quantlib。
我使用的是 64 位ubuntu18.04
上网看了一番,发现少了一个quantlib-python绑定的步骤。为了实现这一点,使用了一个名为 swig 的工具。对于 ubuntu(我用的),可以通过 "apt-get install swig".
安装
然后quantlib-swig需要安装
导航到 quantlib-swig 目录,如果您安装了 boost、quantlib 并且在它们的默认目录中,您可以简单地 运行:
python setup.py wrap
python setup.py build
python setup.py install
并测试它:
python setup.py test
在那之后,您可以快速 "jupyter notebook" 并立即开始测试一些 quantlib 代码:
参考:
我正在关注 Luigi Ballabio 的 "quantlib python cookbook",它使用 jupyter notebook 作为示例。
第一个问题是,我不知道如何在jupyter notebook环境下安装quantlib-python,无法启动
好吧,我可以先启动 anaconda 并从它的仪表板中取出 jupyter notebook,但是一个简单的:
import quantlib as ql
此消息失败。
ModuleNotFoundError: No module named 'quantlib'
来自 运行 "conda list" 我注意到在 conda 默认发货的 python 包中不存在任何与 quantlib 相关的内容。
很好。从这个 link:https://anaconda.org/domosute/quantlib,我设法安装了它并且 "conda list" 显示:
quantlib 1.15 0 domosute
quantlib-python 1.15 pypi_0 pypi
然后我重启了anaconda -> jupyter notebook,仍然抱怨找不到quantlib。
我还应该做些什么才能开始在 jupyter notebook 中使用 quantlib。
我使用的是 64 位ubuntu18.04
上网看了一番,发现少了一个quantlib-python绑定的步骤。为了实现这一点,使用了一个名为 swig 的工具。对于 ubuntu(我用的),可以通过 "apt-get install swig".
安装然后quantlib-swig需要安装
导航到 quantlib-swig 目录,如果您安装了 boost、quantlib 并且在它们的默认目录中,您可以简单地 运行:
python setup.py wrap
python setup.py build
python setup.py install
并测试它:
python setup.py test
在那之后,您可以快速 "jupyter notebook" 并立即开始测试一些 quantlib 代码:
参考: