简体   繁体   中英

QuantLib-Python unable to detect QuantLib installation and fatal error C1083

I have installed QuantLib and boost (I guess correctly). All the examples work fine in C/C++ through visual studio 2017.

Now I want to install the QuantLib-Python version. I have an issue similar to

Python binding through QuantLib-SWIG

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. 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. 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. As in the question you linked, you should set it to the path of your QuantLib folder. 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.)

Update : after setting QL_DIR , I see you're still getting the error "Cannot open include file: '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; 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?

In short, I'd check the value of QL_DIR as seen from the command prompt; 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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