安装Quantlib Python PyQL库:似乎无法找到Boost

时间:2014-01-20 15:38:43

标签: python boost quantlib

我正在尝试安装包含Quantlib的Python PyQL库,但它似乎未能找到一些boost标头。

我已经安装了最新版本的Quantlib(1.3)并位于/ usr / local / lib目录中,以及Boost 1.5:

xxx@LILJEN:/usr/local/lib$ ls
boost  boost_1_50_0  libQuantLib.a  libQuantLib.la  libQuantLib.so  libQuantLib.so.0  libQuantLib.so.0.0.0  python2.7  python3.3  QuantLib-1.3  QuantLib-SWIG-1.3  R  site_ruby

我安装了Cython 0.2:

>>> pkg_resources.get_distribution("Cython").version
'0.20'

当我进入我下载软件包并执行make build命令的pyql目录时,我遇到了Boost库的问题,否则它似乎是" Cythonizing"正确地适应。我注意到Github指令说我应该"补丁" Cython 0.16,但由于我已经在0.2,我认为这不是必要的。以下是构建内容:

xxx@LILJEN:~/Downloads/pyql$ sudo make build
python setup.py build_ext --inplace
/usr/lib/python2.7/distutils/extension.py:133: UserWarning: Unknown Extension options: 'pyrex_directives'
  warnings.warn(msg)
missing cimport in module 'quantlib.time': quantlib/instruments/credit_default_swap.pyx
missing cimport in module 'quantlib.pricingengines': quantlib/instruments/credit_default_swap.pyx
missing cimport in module 'quantlib.pricingengines': quantlib/instruments/option.pyx
Compiling quantlib/quotes.pyx because it changed.
Compiling quantlib/interest_rate.pyx because it changed.
Compiling quantlib/time/calendar.pyx because it changed.
Compiling quantlib/time/schedule.pyx because it changed.
Compiling quantlib/time/date.pyx because it changed.
Compiling quantlib/time/daycounter.pyx because it changed.
Compiling quantlib/time/daycounters/actual_actual.pyx because it changed.
Compiling quantlib/time/daycounters/thirty360.pyx because it changed.
Compiling quantlib/time/calendars/germany.pyx because it changed.
Compiling quantlib/time/calendars/united_states.pyx because it changed.
Compiling quantlib/time/calendars/united_kingdom.pyx because it changed.
Compiling quantlib/time/calendars/null_calendar.pyx because it changed.
Compiling quantlib/time/calendars/jointcalendar.pyx because it changed.
Compiling quantlib/instruments/swap.pyx because it changed.
Compiling quantlib/pricingengines/credit.pyx because it changed.
Compiling quantlib/pricingengines/swap.pyx because it changed.
Compiling quantlib/pricingengines/bond.pyx because it changed.
Compiling quantlib/pricingengines/blackformula.pyx because it changed.
Compiling quantlib/pricingengines/engine.pyx because it changed.
Compiling quantlib/pricingengines/vanilla/mcvanillaengine.pyx because it changed.
Compiling quantlib/pricingengines/vanilla/vanilla.pyx because it changed.
Compiling quantlib/sim/simulate.pyx because it changed.
Compiling quantlib/processes/bates_process.pyx because it changed.
Compiling quantlib/processes/black_scholes_process.pyx because it changed.
Compiling quantlib/processes/heston_process.pyx because it changed.
Compiling quantlib/math/optimization.pyx because it changed.
Compiling quantlib/termstructures/default_term_structure.pyx because it changed.
Compiling quantlib/termstructures/credit/piecewise_default_curve.pyx because it changed.
Compiling quantlib/termstructures/credit/default_probability_helpers.pyx because it changed.
Compiling quantlib/termstructures/volatility/equityfx/black_vol_term_structure.pyx because it changed.
Compiling quantlib/termstructures/yields/yield_term_structure.pyx because it changed.
Compiling quantlib/termstructures/yields/zero_curve.pyx because it changed.
Compiling quantlib/termstructures/yields/piecewise_yield_curve.pyx because it changed.
Compiling quantlib/termstructures/yields/rate_helpers.pyx because it changed.
Compiling quantlib/termstructures/yields/flat_forward.pyx because it changed.
Compiling quantlib/models/equity/bates_model.pyx because it changed.
Compiling quantlib/models/equity/heston_model.pyx because it changed.
Cythonizing quantlib/instruments/swap.pyx
Cythonizing quantlib/interest_rate.pyx
Cythonizing quantlib/math/optimization.pyx
Cythonizing quantlib/models/equity/bates_model.pyx
Cythonizing quantlib/models/equity/heston_model.pyx
Cythonizing quantlib/pricingengines/blackformula.pyx
Cythonizing quantlib/pricingengines/bond.pyx
Cythonizing quantlib/pricingengines/credit.pyx
Cythonizing quantlib/pricingengines/engine.pyx
Cythonizing quantlib/pricingengines/swap.pyx
Cythonizing quantlib/pricingengines/vanilla/mcvanillaengine.pyx
Cythonizing quantlib/pricingengines/vanilla/vanilla.pyx
Cythonizing quantlib/processes/bates_process.pyx
Cythonizing quantlib/processes/black_scholes_process.pyx
Cythonizing quantlib/processes/heston_process.pyx
Cythonizing quantlib/quotes.pyx
Cythonizing quantlib/sim/simulate.pyx
Cythonizing quantlib/termstructures/credit/default_probability_helpers.pyx
Cythonizing quantlib/termstructures/credit/piecewise_default_curve.pyx
Cythonizing quantlib/termstructures/default_term_structure.pyx
Cythonizing quantlib/termstructures/volatility/equityfx/black_vol_term_structure.pyx
Cythonizing quantlib/termstructures/yields/flat_forward.pyx
Cythonizing quantlib/termstructures/yields/piecewise_yield_curve.pyx
Cythonizing quantlib/termstructures/yields/rate_helpers.pyx
Cythonizing quantlib/termstructures/yields/yield_term_structure.pyx
Cythonizing quantlib/termstructures/yields/zero_curve.pyx
Cythonizing quantlib/time/calendar.pyx
Cythonizing quantlib/time/calendars/germany.pyx
Cythonizing quantlib/time/calendars/jointcalendar.pyx
Cythonizing quantlib/time/calendars/null_calendar.pyx
Cythonizing quantlib/time/calendars/united_kingdom.pyx
Cythonizing quantlib/time/calendars/united_states.pyx
Cythonizing quantlib/time/date.pyx
Cythonizing quantlib/time/daycounter.pyx
Cythonizing quantlib/time/daycounters/actual_actual.pyx
Cythonizing quantlib/time/daycounters/thirty360.pyx
Cythonizing quantlib/time/schedule.pyx
running build_ext
building 'quantlib.cashflow' extension
creating build
creating build/temp.linux-x86_64-2.7
creating build/temp.linux-x86_64-2.7/quantlib
x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -DHAVE_CONFIG_H -I/usr/local/include -I/usr/include -I. -I./cpp_layer -I/usr/include/python2.7 -c quantlib/cashflow.cpp -o build/temp.linux-x86_64-2.7/quantlib/cashflow.o
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++ [enabled by default]
quantlib/cashflow.cpp:342:32: fatal error: boost/shared_ptr.hpp: No such file or directory
 #include "boost/shared_ptr.hpp"
                                ^
compilation terminated.
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
make: *** [build] Error 1

它似乎无法找到boost库,即使这已经明确安装并正常工作,因为我从头开始成功编译了Quantlib并且测试套件正常工作。关于我可能出错的地方的任何暗示?

它的Ubuntu 13.10和默认安装的Python 2.7。基本上这是一个新安装的系统,包含所有最新的库(除了Boost,我保持在1.5)。

Fwiw python setup.py安装也不起作用,但我有常规的SWIG Quantlib库在Python中运行良好。


附录

我相信"错误"我的意思是我密切关注this excellent page如何在Ubuntu上安装Quantlib。该页面讨论了usr / local / lib目录中的Boost,并复制并粘贴了它的命令。 Quantlib编译得很完美,因为Boost目录是按照页面的export命令进行通信的,但是pyql也需要在setup.py中指定这个目录。这是确保sys.platform =" linux2"下的行,指定INCLUDE_DIRS到usr / local / lib而不是默认的usr / local / include。我写这个附录是因为我相信很多用户也可以google搜索"安装Quantlib Ubuntu"并找到此页面,因此这个问题可能会再次出现在许多人身上。

1 个答案:

答案 0 :(得分:1)

如果查看启动编译器的命令行,您将看到

-I/usr/local/include -I/usr/include -I. -I./cpp_layer -I/usr/include/python2.7

这些标志告诉编译器在哪里查找标头。你的Boost标题不在其中任何一个(这很奇怪:标题通常在/ usr / local / include中的某处。你自己在/ usr / local / lib中复制它们吗?)所以编译器找不到它们。

你可以:

  • 移动/ usr / local / include中的boost目录(即名为“boost”的目录,而不是名为“boost_1_50_0”的目录)或
  • 将另一个标志-I/usr/local/lib/boost_1_50_0传递给编译器,以便它可以在当前位置找到它们。执行此操作的方法取决于您的setup.py脚本。