我一直在嘗試安裝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?另外,你使用的是什麼編譯器版本? –