我下载了 QuantLib-SWIG-1.19 for Windows 10 。
我能够构建和安装 python 版本。
但是当它尝试运行 build_ext 时,测试失败了。
SET QL_DIR=C:\Users\admuser\Workspace\QuantLib-1.19
SET INCLUDE=C:\Users\admuser\ThirdParty\boost_1_74_0;%INCLUDE%
SET LIB=C:\Users\admuser\ThirdParty\boost_1_74_0;%LIB%
set PATH=%PATH%;C:\Users\admuser\ThirdParty\swigwin\swigwin-4.0.2
cd C:\Users\admuser\Workspace\QuantLib-SWIG-1.19\Python
调用了以下命令
python setup.py build
python setup.py install
python setup.py test
python setup.py 测试 build_ext 失败
running test
running build
running build_py
running build_ext
Traceback (most recent call last):
File "setup.py", line 237, in <module>
setup(name = "QuantLib",
File "C:\Users\admuser\ThirdParty\WinPython\python-3.8.2.amd64\lib\site-packages\setuptools\__init__.py", line 144, in setup
return distutils.core.setup(**attrs)
File "C:\Users\admuser\ThirdParty\WinPython\python-3.8.2.amd64\lib\distutils\core.py", line 148, in setup
dist.run_commands()
File "C:\Users\admuser\ThirdParty\WinPython\python-3.8.2.amd64\lib\distutils\dist.py", line 966, in run_commands
self.run_command(cmd)
File "C:\Users\admuser\ThirdParty\WinPython\python-3.8.2.amd64\lib\distutils\dist.py", line 985, in run_command
cmd_obj.run()
File "setup.py", line 61, in run
module = __import__('QuantLibTestSuite', globals(), locals(), [''])
File "test\QuantLibTestSuite.py", line 22, in <module>
from date import DateTest
File "test\date.py", line 18, in <module>
import QuantLib as ql
File "build\lib.win-amd64-3.8\QuantLib\__init__.py", line 21, in <module>
from .QuantLib import *
File "build\lib.win-amd64-3.8\QuantLib\QuantLib.py", line 13, in <module>
from . import _QuantLib
ImportError: DLL load failed while importing _QuantLib: The parameter is incorrect.
setup.py build 创建了一个带有临时目录和 lib 目录的文件夹:
QuantLib-SWIG-1.19\Python\build\lib.win-amd64-3.8\QuantLib
which contains
__init__.py
_QuantLib.cp38-win_amd64.pyd
QuantLib.py
setup.py install 添加:
QuantLib-SWIG-1.19\Python\QuantLib.egg-info
QuantLib-SWIG-1.19\Python\build\lib.win-amd64-3.8\QuantLib\__pycache__
python-3.8.2.amd64\Lib\site-packages\QuantLib-1.19-py3.8-win-amd64.egg
python-3.8.2.amd64\Lib\site-packages\QuantLib-1.19-py3.8-win-amd64.egg\QuantLib
which contains:
__pycache__ folder
__init__.py
_QuantLib.cp38-win_amd64.pyd
_QuantLib.py
QuantLib.py
所以我尝试导入 QuantLib:
我打开了一个管理命令提示符窗口,它可以工作:
C:\WINDOWS\system32>python
Python 3.8.2 (tags/v3.8.2:7b3ab59, Feb 25 2020, 23:03:10) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import QuantLib as ql
>>> QuantLib.__file__
'C:\\Users\\admuser\\ThirdParty\\WinPython\\python-3.8.2.amd64\\lib\\site-packages\\quantlib-1.19-py3.8-win-amd64.egg\\QuantLib\\__init__.py'
>>>
但后来我 cd C:\Users\admuser\Workspace\QuantLib-SWIG-1.19\Python
(我需要在那里 cd 才能运行 python setup.py)
C:\Users\admuser\Workspace\QuantLib-SWIG-1.19\Python>python
Python 3.8.2 (tags/v3.8.2:7b3ab59, Feb 25 2020, 23:03:10) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>import QuantLib as ql
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\admuser\Workspace\QuantLib-SWIG-1.19\Python\QuantLib\__init__.py", line 21, in <module>
from .QuantLib import *
File "C:\Users\admuser\Workspace\QuantLib-SWIG-1.19\Python\QuantLib\QuantLib.py", line 13, in <module>
from . import _QuantLib
ImportError: cannot import name '_QuantLib' from partially initialized module 'QuantLib' (most likely due to a circular import) (C:\Users\admuser\Workspace\QuantLib-SWIG-1.19\Python\QuantLib\__init__.py)
>>>
´´´