Quantlib-SWIG 1.12.x for Python error, missing Quantlib/quantlib_wrap.cpp in windows

倖福魔咒の 提交于 2019-12-11 08:57:35

问题


I downloaded both Quantlib-SWIG 1.12.x and Quantlib 1.12.x from github. Quantlib is compiled without and problems. The examples ran normally. However, when run python setup.py build, there is an error indicating missing quantlib_wrap.cpp. Where to download the proper quantlib_wrap.cpp for this version or this error is related to something else? Here is the messages I got from this build.

C:\Users\Public\3rdParty\Libraries\QuantLib-SWIG-1.12.x\Python>python setup.py build
running build
running build_py
file QuantLib\QuantLib.py (for module QuantLib.QuantLib) not found
file QuantLib\QuantLib.py (for module QuantLib.QuantLib) not found
running build_ext
building 'QuantLib._QuantLib' extension
C:\Users\U435169\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0\VC\Bin\cl.exe /c /nologo /Ox /MD /W3 /GS- /DNDEBUG -D__WIN32__ -DWIN32 -DNDEBUG -D_WINDOWS -DNOMINMAX -Id:\packages\Python27\include -Id:\packages\Python27\PC -IC:\Users\Public\3rdParty\Libraries\QuantLib-master /TpQuantLib/quantlib_wrap.cpp /Fobuild\temp.win32-2.7\Release\QuantLib/quantlib_wrap.obj /GR /FD /Zm250 /EHsc /bigobj /MD
quantlib_wrap.cpp
c1xx : fatal error C1083: Cannot open source file: 'QuantLib/quantlib_wrap.cpp': No such file or directory
error: command 'C:\\Users\\U435169\\AppData\\Local\\Programs\\Common\\Microsoft\\Visual C++ for Python\\9.0\\VC\\Bin\\cl.exe' failed with exit status 2

回答1:


quantlib_wrap.cpp is generated by SWIG using the sources in the repository. If you have SWIG installed, you can generate it (see https://www.quantlib.org/install/windows-python.shtml); but if you don't have plans to modify the sources, I suggest that you either:

  • instead of cloning the repo from GitHub, download an official release (see https://www.quantlib.org/download.shtml); released sources include quantlib_wrap.cpp;

  • or better yet, as suggested in the install page linked above, try running

    pip install QuantLib-Python
    

    to see if a precompiled Python module is available from PyPI. If that succeeds, you'll be set without having to compile the thing yourself.



来源:https://stackoverflow.com/questions/53385447/quantlib-swig-1-12-x-for-python-error-missing-quantlib-quantlib-wrap-cpp-in-win

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!