0

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 
Oscar
  • 460
  • 3
  • 18
  • I got similar issues because I didn't notice I had Powershell as a shell instead of cmd haha, after switching to cmd I got quantlib.org/install/windows-python.shtml working however setup.py throws SetuptoolsDeprecationWarning: setup.py install is deprecated. @luigi-ballabio – BigChief Aug 11 '23 at 14:18

1 Answers1

1

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.

Luigi Ballabio
  • 4,128
  • 21
  • 29
  • Thanks, however "pip install QuantLib-Python" does not work, so it seems there is no precompiled binary available. I set `QL_DIR = my\path\to\Quantlib` and now the message `warning: unable to detect QuantLib installation` disappeared, but I got the same C1083 error – Oscar May 29 '18 at 13:22
  • Please update the question with the exact message you're getting now. – Luigi Ballabio May 29 '18 at 13:37
  • I have the same issue... did anyone figure out how to fix this? I'm trying to install the Python-SWIG wrapper for QuantLib and the wrap goes fine, but the build script can't find anything defined in QL_DIR set as an environment variable. If I hardcode the path in the quantlib_wrap.cpp then the next file that needs to be included (from #include ) can't find find the directory either. I've checked the environment variables are set properly. I'm trying to test out the singleton fix in 1.24.dev because I think it will fix another library that's had issues with the singleton. – Matt Aug 17 '21 at 19:32