在“苹果硅”Macbook上运行QuantLib python

2024-05-14 04:13:57 发布

您现在位置:Python中文网/ 问答频道 /正文

我尝试在带有M1处理器(Big Sur v11.3)的Macbook上运行Quantlib Python,如下https://www.quantlib.org/install/macosx-python.shtml。我已通过自制成功安装了Quantlib 1.22和Python 3.9.4:

Pouring quantlib--1.22.arm64_big_sur.bottle.tar.gz进入“/opt/homebrew/ceral/quantlib/1.22”

然而,当我尝试通过pip安装Quantlib Python时,我得到:

ERROR: Could not find a version that satisfies the requirement QuantLib (from versions: none)
ERROR: No matching distribution found for QuantLib

由此看来,虽然Quantlib 1.22已经为基于arm的OSX做好了准备,但Quantlib Python却没有

然后,我正尝试按照上面的链接从发布的版本进行安装:

tar xzf QuantLib-SWIG-1.22.tar.gz
cd QuantLib-SWIG-1.22/Python
export CXXFLAGS='-O2 -std=c++11 -stdlib=libc++ -mmacosx-version-min=10.9'
export LDFLAGS='-stdlib=libc++ -mmacosx-version-min=10.9'
python setup.py build

但我得到了以下错误:

cd QuantLib-SWIG-1.22/Python
  export CXXFLAGS='-O2 -std=c++11 -stdlib=libc++ -mmacosx-version-min=10.9'
  export LDFLAGS='-stdlib=libc++ -mmacosx-version-min=10.9'
  python setup.py build
running build
running build_py
running build_ext
building 'QuantLib._QuantLib' extension
clang -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include -DNDEBUG -I/Users/USER/coding/project1/include -I/Users/USER/.pyenv/versions/3.9.4/include/python3.9 -I/opt/homebrew/Cellar/quantlib/1.22/include -c QuantLib/quantlib_wrap.cpp -o build/temp.macosx-11.3-arm64-3.9/QuantLib/quantlib_wrap.o -Wno-unused -O2 -std=c++11 -stdlib=libc++ -mmacosx-version-min=10.9
In file included from QuantLib/quantlib_wrap.cpp:4730:
In file included from /opt/homebrew/Cellar/quantlib/1.22/include/ql/version.hpp:28:
/opt/homebrew/Cellar/quantlib/1.22/include/ql/qldefines.hpp:38:10: fatal error: 'boost/config.hpp' file not found
#include <boost/config.hpp>
         ^~~~~~~~~~~~~~~~~~
1 error generated.
error: command '/usr/bin/clang' failed with exit code 1

我已经尝试了很多解决boost问题的方法,并且查看了很多其他问题/答案,但是还没有找到解决方法。这是旗帜的问题吗?有人有幸让QuantLib Python在基于M1的OSX上工作吗


Tags: builddeveloperincludeversionlibexportminmacosx