我一直在尝试安装QuantLib并希望在Python中使用它。但是,我在构建Quantlib-SWIG方面遇到了很大的麻烦,希望能在这里获得一些帮助。Quantlib SWIG python安装失败
我能够按照http://quantlib.org/install/macosx.shtml(如果有问题,我在Lion上)的程序成功地构建Quantlib并运行所有测试套件。我下载并解压Quantlib-SWIG和尝试做的python setup.py构建之后,我得到了很多的错误,都似乎有所重复以下内容:
QuantLib/quantlib_wrap.cpp:5640: instantiated from ‘static int swig::traits_asptr<std::vector<T, std::allocator<_CharT> > >::asptr(PyObject*, std::vector<T, std::allocator<_CharT> >**) [with T = boost::shared_ptr<QuantLib::Quote>]’
QuantLib/quantlib_wrap.cpp:4663: instantiated from ‘int swig::asptr(PyObject*, Type**) [with Type = std::vector<boost::shared_ptr<QuantLib::Quote>, std::allocator<boost::shared_ptr<QuantLib::Quote> > >]’
QuantLib/quantlib_wrap.cpp:43476: instantiated from here
/opt/local/include/boost/assign/assignment_exception.hpp:24: error: ‘boost::assign’ is not a function,
QuantLib/quantlib_wrap.cpp:5558: error: conflict with ‘template<class SwigPySeq, class Seq> void swig::assign(const SwigPySeq&, Seq*)’
QuantLib/quantlib_wrap.cpp:5585: error: in call to ‘assign’
/opt/local/include/boost/assign/assignment_exception.hpp: In static member function ‘static int swig::traits_asptr_stdseq<Seq, T>::asptr(PyObject*, Seq**) [with Seq = std::vector<std::vector<boost::shared_ptr<QuantLib::Quote>, std::allocator<boost::shared_ptr<QuantLib::Quote> > >, std::allocator<std::vector<boost::shared_ptr<QuantLib::Quote>, std::allocator<boost::shared_ptr<QuantLib::Quote> > > > >, T = std::vector<boost::shared_ptr<QuantLib::Quote>, std::allocator<boost::shared_ptr<QuantLib::Quote> > >]’:
QuantLib/quantlib_wrap.cpp:5640: instantiated from ‘static int swig::traits_asptr<std::vector<T, std::allocator<_CharT> > >::asptr(PyObject*, std::vector<T, std::allocator<_CharT> >**) [with T = std::vector<boost::shared_ptr<QuantLib::Quote>, std::allocator<boost::shared_ptr<QuantLib::Quote> > >]’
QuantLib/quantlib_wrap.cpp:4663: instantiated from ‘int swig::asptr(PyObject*, Type**) [with Type = std::vector<std::vector<boost::shared_ptr<QuantLib::Quote>, std::allocator<boost::shared_ptr<QuantLib::Quote> > >, std::allocator<std::vector<boost::shared_ptr<QuantLib::Quote>, std::allocator<boost::shared_ptr<QuantLib::Quote> > > > >]’
QuantLib/quantlib_wrap.cpp:45813: instantiated from here
/opt/local/include/boost/assign/assignment_exception.hpp:24: error: ‘boost::assign’ is not a function,
QuantLib/quantlib_wrap.cpp:5558: error: conflict with ‘template<class SwigPySeq, class Seq> void swig::assign(const SwigPySeq&, Seq*)’
QuantLib/quantlib_wrap.cpp:5585: error: in call to ‘assign’
/opt/local/include/boost/assign/assignment_exception.hpp: In static member function ‘static int swig::traits_asptr_stdseq<Seq, T>::asptr(PyObject*, Seq**) [with Seq = std::vector<boost::shared_ptr<QuantLib::StochasticProcess>, std::allocator<boost::shared_ptr<QuantLib::StochasticProcess> > >, T = boost::shared_ptr<QuantLib::StochasticProcess>]’:
QuantLib/quantlib_wrap.cpp:5640: instantiated from ‘static int swig::traits_asptr<std::vector<T, std::allocator<_CharT> > >::asptr(PyObject*, std::vector<T, std::allocator<_CharT> >**) [with T = boost::shared_ptr<QuantLib::StochasticProcess>]’
QuantLib/quantlib_wrap.cpp:4663: instantiated from ‘int swig::asptr(PyObject*, Type**) [with Type = std::vector<boost::shared_ptr<QuantLib::StochasticProcess>, std::allocator<boost::shared_ptr<QuantLib::StochasticProcess> > >]’
QuantLib/quantlib_wrap.cpp:124772: instantiated from here
/opt/local/include/boost/assign/assignment_exception.hpp:24: error: ‘boost::assign’ is not a function,
QuantLib/quantlib_wrap.cpp:5558: error: conflict with ‘template<class SwigPySeq, class Seq> void swig::assign(const SwigPySeq&, Seq*)’
QuantLib/quantlib_wrap.cpp:5585: error: in call to ‘assign’
我想痛饮一对夫妇版本Quantlib-SWIG似乎没有任何运气。我试过SWIG 3.0.6和3.0.2。 Quantlib-SWIG 1.5和1.6。我的Quantlib版本是1.6,并且从macports安装时应该是最新版本。
有什么我失踪?
看起来您并不是唯一一个遇到这个问题的人:请参阅https://dev.lsstcorp.org/trac/ticket/1249获取与QuantLib无关的类似报告。不过,这是我第一次听说它。你可以检查你使用的是什么版本的Boost吗?您应该在中找到信息。 –
#define BOOST_VERSION 105800 – Wesley
所以这是最新的一个。只是为了排除它在SWIG安装上的某些问题,您是否可以尝试发布的QuantLib-SWIG 1.6并使用包含的文件而不运行SWIG?另外,你使用的是什么编译器版本? –