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

时间:2018-05-29 12:28:09

标签: python windows quantitative-finance quantlib quantlib-swig

我已经安装了QuantLib和boost(我猜对了)。所有这些例子都可以通过Visual Studio 2017在C / C ++中正常运行。

现在我想安装QuantLib-Python版本。我有类似

的问题

Python binding through QuantLib-SWIG

但是,当我设置环境变量时,我删除了=符号周围的空格。 (我还通过“我的电脑” - >“属性 - >高级系统设置 - >环境变量”添加了environemnt变量的路径,但是QuantLib python的构建仍然无法正常工作。我得到了以下输出

(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

编辑更新

感谢Luigi Ballabio的回答,我正确地设置了QL_DIR。现在我得到的错误消息是以下

(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 

1 个答案:

答案 0 :(得分:1)

警告"无法检测QuantLib安装"表示安装脚本无法读取QL_DIR环境变量。与您链接的问题一样,您应将其设置为QuantLib文件夹的路径。设置之后,可能必须重新启动从中构建包装器的命令提示符。

(这就是说,在构建包装器之前,请尝试运行

pip install QuantLib-Python

根据您的Python版本,您可能会获得预编译的二进制文件。)

更新:设置QL_DIR后,我发现您仍然收到错误"无法打开包含文件:' ql / version.hpp&# 39;&#34 ;.这指向包含目录未正确设置,实际上您的命令行包含一个无法正常工作的开关-IC:\opt-libs\QuantLib-1.13;C:\opt-libs\QuantLib-1.13\lib;C:\opt-libs\QuantLib-1.13\ql,因为-I不会记录路径列表;它应该是-IC:\opt-libs\QuantLib-1.13基于您的QL_DIR,我认为C:\opt-libs\QuantLib-1.13 - 我是否正确?

简而言之,我从命令提示符处查看QL_DIR的值;你可以用

显示它
echo %QL_DIR%

如果是路径列表,请将其重置为指向QuantLib目录的单个路径。