简体   繁体   English

Quantlib-Python安装中没有名为_QuantLib的模块

[英]No module named _QuantLib, Quantlib-Python installation

I am trying to install Quantlib-Python on my Mac ( official instructions ), but when I run make -C Python check , I receive an error ImportError: No module named _QuantLib . 我试图在Mac上安装Quantlib-Python( 官方说明 ),但是当我运行make -C Python check ,出现错误ImportError: No module named _QuantLib When I revisit the installation steps it seems like everything is working: 当我重新访问安装步骤时,似乎一切正常:

Removing /Library/Python/2.7/site-packages/QuantLib_Python-1.9-py2.7.egg-info
Writing /Library/Python/2.7/site-packages/QuantLib_Python-1.9-py2.7.egg-info

Any idea what is going wrong? 知道出了什么问题吗?

Python might be failing to find your dynamic C++ QuantLib library. Python可能无法找到动态C ++ QuantLib库。 It should probably be called libQuantLib.dylib and should be where the dynamic loader can find it; 它可能应该称为libQuantLib.dylib并且应该是动态加载程序可以找到它的位置。 that means that it should be in some standard system location like /usr/lib or /usr/local/lib , or that you should set the environment variable DYLD_LIBRARY_PATH so that it includes its location. 这意味着它应该位于某个标准系统位置,例如/usr/lib/usr/local/lib ,或者您应该设置环境变量DYLD_LIBRARY_PATH使其包含其位置。

If you only want to use the QuantLib Python module, an easier alternative might be to sidestep dynamic loading. 如果您只想使用QuantLib Python模块,则更简单的选择是避免动态加载。 If you clean up your installation (that is, if you remove any libQuantLib.* that you might have installed) and you rebuild the C++ QuantLib by first configuring it as 如果清理安装(也就是说,如果删除了可能已安装的任何libQuantLib.* ),然后通过首先将C ++ QuantLib配置为

./configure --disable-shared --enable-static

(plus any other flags you might need), when you run make you'll get a static library. (加上您可能需要的任何其他标志),当您运行make您将获得一个静态库。 When you rebuild the Python wrappers, the Python module will then embed the QuantLib code itself instead of relying on the presence of the dynamic library. 当您重建Python包装器时,Python模块将自行嵌入QuantLib代码,而不是依赖于动态库的存在。

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

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