简体   繁体   English

QuantLib-Python无法检测到QuantLib安装和致命错误C1083

[英]QuantLib-Python unable to detect QuantLib installation and fatal error C1083

I have installed QuantLib and boost (I guess correctly). 我已经安装了QuantLib和boost(我猜是正确的)。 All the examples work fine in C/C++ through visual studio 2017. 通过Visual Studio 2017,所有示例都可以在C / C ++中正常运行。

Now I want to install the QuantLib-Python version. 现在,我想安装QuantLib-Python版本。 I have an issue similar to 我有一个类似的问题

Python binding through QuantLib-SWIG 通过QuantLib-SWIG进行Python绑定

however, I removed the spaces around the = signs when I set the environment variables. 但是,在设置环境变量时,我删除了=号周围的空格。 (I also added that paths to the environemnt variables through My Computer -> properties -> advanced system settings -> environment variables) but the building of QuantLib python keeps not working. (我还添加了通过我的电脑->属性->高级系统设置->环境变量到环境变量的路径),但QuantLib python的构建仍然无法正常工作。 I got the following output 我得到以下输出

(base) C:\opt-libs\QuantLib-SWIG-1.13\Python>python setup.py build
running build
running build_py
running build_ext
warning: unable to detect QuantLib installation
building 'QuantLib._QuantLib' extension
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.14.26428\bin\HostX86\x86\cl.exe/c/nologo /Ox /W3 /GL /DNDEBUG /MD -D__WIN32__ -DWIN32 -DNDEBUG -D_WINDOWS -DNOMINMAX "-IC:\Program Files (x86)\Microsoft Visual Studio\Shared\Anaconda3_86\include" "-IC:\Program Files (x86)\Microsoft Visual Studio\Shared\Anaconda3_86\include" -IC:\opt-libs\boost_1_67_0 "-IC:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.14.26428\ATLMFC\include" "-IC:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.14.26428\include" "-IC:\Program Files (x86)\Windows Kits\NETFXSDK\4.6.1\include\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17134.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17134.0\shared" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17134.0\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17134.0\winrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17134.0\cppwinrt" -IC:\opt-libs\boost_1_67_0 /EHsc /TpQuantLib/quantlib_wrap.cpp /Fobuild\temp.win32-3.6\Release\QuantLib/quantlib_wrap.obj /GR /FD /Zm250 /EHsc /bigobj /MD quantlib_wrap.cpp
QuantLib/quantlib_wrap.cpp(4000): fatal error C1083: Cannot open include file: 'ql/version.hpp': No such file or directory
error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\Community\\VC\\Tools\\MSVC\\14.14.26428\\bin\\HostX86\\x86\\cl.exe' failed with exit status 2

Edit Update 编辑更新

Thanks to the kind answer of Luigi Ballabio, I set the QL_DIR correctly. 感谢Luigi Ballabio的QL_DIR回答,我正确设置了QL_DIR Now the error message I get is the following 现在我得到的错误信息如下

(base) C:\opt-libs\QuantLib-SWIG-1.13\Python>python setup.py build
running build
running build_py
running build_ext
building 'QuantLib._QuantLib' extension
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.14.26428\bin\HostX86\x86\cl.exe /c/nologo /Ox /W3 /GL /DNDEBUG /MD -D__WIN32__ -DWIN32 -DNDEBUG -D_WINDOWS -DNOMINMAX "-IC:\Program Files (x86)\Microsoft Visual Studio\Shared\Anaconda3_86\include" "-IC:\Program Files (x86)\Microsoft Visual Studio\Shared\Anaconda3_86\include" -IC:\opt-libs\QuantLib-1.13;C:\opt-libs\QuantLib-1.13\lib;C:\opt-libs\QuantLib-1.13\ql -IC:\opt-libs\boost_1_67_0 "-IC:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.14.26428\ATLMFC\include" "-IC:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.14.26428\include" "-IC:\Program Files (x86)\Windows Kits\NETFXSDK\4.6.1\include\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17134.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17134.0\shared" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17134.0\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17134.0\winrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17134.0\cppwinrt" -IC:\opt-libs\boost_1_67_0 /EHsc /TpQuantLib/quantlib_wrap.cpp /Fobuild\temp.win32-3.6\Release\QuantLib/quantlib_wrap.obj /GR /FD /Zm250 /EHsc /bigobj /MD quantlib_wrap.cpp
QuantLib/quantlib_wrap.cpp(4000): fatal error C1083: Cannot open include file: 'ql/version.hpp': No such file or directory
error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\Community\\VC\\Tools\\MSVC\\14.14.26428\\bin\\HostX86\\x86\\cl.exe' failed with exit status 2 

The warning "unable to detect QuantLib installation" means that the setup script is not able to read the QL_DIR environment variable. 警告“无法检测到QuantLib安装”意味着安装脚本无法读取QL_DIR环境变量。 As in the question you linked, you should set it to the path of your QuantLib folder. 就像您链接的问题一样,您应该将其设置为QuantLib文件夹的路径。 After you set it, you might have to restart the command prompt from which you're building the wrappers. 设置完之后,可能必须重新启动用于构建包装器的命令提示符。

(This said, before building the wrappers, try running (这就是说,在构建包装器之前,请尝试运行

pip install QuantLib-Python

Depending on your Python version, there's a chance that you might get a precompiled binary.) 根据您的Python版本,您可能会获得预编译的二进制文件。)

Update : after setting QL_DIR , I see you're still getting the error "Cannot open include file: 'ql/version.hpp'". 更新 :设置QL_DIR ,我仍然看到错误“无法打开包含文件:'ql / version.hpp'”。 This points to the include directories not being set up correctly, and in fact your command line contains a switch -IC:\\opt-libs\\QuantLib-1.13;C:\\opt-libs\\QuantLib-1.13\\lib;C:\\opt-libs\\QuantLib-1.13\\ql which can't work, because -I doesn't take lists of paths; 这指向未正确设置包含目录,实际上您的命令行包含一个开关-IC:\\opt-libs\\QuantLib-1.13;C:\\opt-libs\\QuantLib-1.13\\lib;C:\\opt-libs\\QuantLib-1.13\\ql无法正常工作,因为-I不获取路径列表; it should be -IC:\\opt-libs\\QuantLib-1.13 based on your QL_DIR , which I suppose is C:\\opt-libs\\QuantLib-1.13 —am I correct? 根据您的QL_DIR ,它应该是-IC:\\opt-libs\\QuantLib-1.13 ,我想是C:\\opt-libs\\QuantLib-1.13 -我正确吗?

In short, I'd check the value of QL_DIR as seen from the command prompt; 简而言之,我将检查从命令提示符处看到的QL_DIR的值; you can display it with 你可以用

echo %QL_DIR%

If it is a list of paths, reset it to the single one that points to the QuantLib directory. 如果它是路径列表,则将其重置为指向QuantLib目录的单个路径。

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

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