QuantLib Python Bindings - Windows

classic Classic list List threaded Threaded
13 messages Options
Reply | Threaded
Open this post in threaded view
|

QuantLib Python Bindings - Windows

newbie730
I am having trouble compiling the python bindings in windows. I have VC 2008 and VC 2010 installed - the binaries built fine with VC 2008.

QL_DIR is currently set to the QuantLib source directory as downloaded using SVN
>echo %QL_DIR%
c:\Users\lcota\workspace\quantlib\QuantLib

the output of the python build command is a bunch of errors like the following

python setup.py build
running build
running build_py
running build_ext
building 'QuantLib._QuantLib' extension
C:\Python26\Scripts\gcc.exe -mno-cygwin -mdll -O -Wall -IC:\Python26\include -IC:\Python26\PC -c QuantLib/quantlib_wrap.cpp -o build
QuantLib/quantlib_wrap.cpp:3423:26: ql/version.hpp: No such file or directory
QuantLib/quantlib_wrap.cpp:3424: error: `QL_HEX_VERSION' was not declared in this scope
QuantLib/quantlib_wrap.cpp:3425: error: `QL_VERSION' was not declared in this scope
QuantLib/quantlib_wrap.cpp:3484:27: ql/quantlib.hpp: No such file or directory
QuantLib/quantlib_wrap.cpp:3487:6: #error using an old version of QuantLib, please update
QuantLib/quantlib_wrap.cpp:3874:48: boost/algorithm/string/case_conv.hpp: No such file or directory
QuantLib/quantlib_wrap.cpp:3878: error: `QuantLib' has not been declared
QuantLib/quantlib_wrap.cpp:3878: error: expected nested-name-specifier before "Error"
QuantLib/quantlib_wrap.cpp:3878: error: `Error' has not been declared
QuantLib/quantlib_wrap.cpp:3879: error: `QuantLib' has not been declared
QuantLib/quantlib_wrap.cpp:3879: error: expected nested-name-specifier before "Handle"
QuantLib/quantlib_wrap.cpp:3879: error: `Handle' has not been declared
QuantLib/quantlib_wrap.cpp:3880: error: `QuantLib' has not been declared
QuantLib/quantlib_wrap.cpp:3880: error: expected nested-name-specifier before "RelinkableHandle"
QuantLib/quantlib_wrap.cpp:3880: error: `RelinkableHandle' has not been declared
QuantLib/quantlib_wrap.cpp:3883: error: `QuantLib' has not been declared
QuantLib/quantlib_wrap.cpp:3883: error: expected nested-name-specifier before "Integer"
QuantLib/quantlib_wrap.cpp:3883: error: `Integer' has not been declared
QuantLib/quantlib_wrap.cpp:3884: error: `QuantLib' has not been declared
QuantLib/quantlib_wrap.cpp:3884: error: expected nested-name-specifier before "BigInteger"
QuantLib/quantlib_wrap.cpp:3884: error: `BigInteger' has not been declared
Reply | Threaded
Open this post in threaded view
|

Re: QuantLib Python Bindings - Windows

Luigi Ballabio
On Tue, 2010-09-14 at 11:50 -0700, newbie730 wrote:

> building 'QuantLib._QuantLib' extension
> C:\Python26\Scripts\gcc.exe

I think Python 2.6 looks for VC++2008.  From the above, it looks like it
doesn't find it, ignores VC++2010, and tries gcc.  I guess you'll have
to stick with VC++2008...

Luigi



--

Innovation is hard to schedule.
-- Dan Fylstra



------------------------------------------------------------------------------
Start uncovering the many advantages of virtual appliances
and start using them to simplify application deployment and
accelerate your shift to cloud computing.
http://p.sf.net/sfu/novell-sfdev2dev
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Reply | Threaded
Open this post in threaded view
|

Re: QuantLib Python Bindings - Windows

Bojan Nikolic

Luigi Ballabio <[hidden email]> writes:

>> building 'QuantLib._QuantLib' extension
>> C:\Python26\Scripts\gcc.exe
>
> I think Python 2.6 looks for VC++2008.  From the above, it looks like it
> doesn't find it, ignores VC++2010, and tries gcc.  I guess you'll have
> to stick with VC++2008...

Publicly distributed Python 2.6 was built with VC++2008.  Although you
might get away with it, it is best to build extensions with same
compiler version that was used to build Python itself, and distutils
indeed looks for the version of VC that the Python it finds was built
with.

A possible alternative to downgrading to VC++2008 is to recompile Python
itself using your VC++2010. I believe that would solve your problem, but
have not tried it myself...


--
Bojan Nikolic          ||          http://www.bnikolic.co.uk/ql/

------------------------------------------------------------------------------
Start uncovering the many advantages of virtual appliances
and start using them to simplify application deployment and
accelerate your shift to cloud computing.
http://p.sf.net/sfu/novell-sfdev2dev
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Reply | Threaded
Open this post in threaded view
|

Re: QuantLib Python Bindings - Windows

newbie730
In reply to this post by Luigi Ballabio
I have VC++ 2008 installed - how can I make sure python distutils finds it?


Luigi Ballabio wrote
On Tue, 2010-09-14 at 11:50 -0700, newbie730 wrote:

> building 'QuantLib._QuantLib' extension
> C:\Python26\Scripts\gcc.exe

I think Python 2.6 looks for VC++2008.  From the above, it looks like it
doesn't find it, ignores VC++2010, and tries gcc.  I guess you'll have
to stick with VC++2008...

Luigi



--

Innovation is hard to schedule.
-- Dan Fylstra



------------------------------------------------------------------------------
Start uncovering the many advantages of virtual appliances
and start using them to simplify application deployment and
accelerate your shift to cloud computing.
http://p.sf.net/sfu/novell-sfdev2dev
_______________________________________________
QuantLib-users mailing list
QuantLib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Reply | Threaded
Open this post in threaded view
|

Re: QuantLib Python Bindings - Windows

Luigi Ballabio
On Wed, 2010-09-15 at 05:05 -0700, newbie730 wrote:
> I have VC++ 2008 installed - how can I make sure python distutils finds it?

On my machine, distutils looks for "C:\Program Files\Microsoft Visual
Studio 9.0\VC\BIN\cl.exe" which, I think, is the default location; I
didn't have to set anything myself.
If you have it installed elsewhere, I'm afraid I can't be of much
help---you might want to search the distutils docs, or ask on some
Python list.

Luigi


--

A programming language is low-level when its programs require attention
to the irrelevant.
-- Alan Perlis



------------------------------------------------------------------------------
Start uncovering the many advantages of virtual appliances
and start using them to simplify application deployment and
accelerate your shift to cloud computing.
http://p.sf.net/sfu/novell-sfdev2dev
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Reply | Threaded
Open this post in threaded view
|

Re: QuantLib Python Bindings - Windows

ElMariachi
Able to make some progress with the compiler issue - turns out my installation of Python had a distutils.cfg file which was setting default compiler to be mingw32. After removing this file, Python correctly attempts to use the CL.exe from VS2008.  Now I am getting some errors finding the boost libraries - this is the latest output:

PS C:\Users\lcota\workspace\quantlib\Quantlib-SWIG\python> python setup.py build
running build
running build_py
running build_ext
building 'QuantLib._QuantLib' extension
c:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\BIN\cl.exe /c /nologo /Ox /MD /W3 /GS- /DNDEBUG -D__WIN32__ -DWIN3
2 -DNDEBUG -D_WINDOWS -DNOMINMAX -IC:\Python26\include -IC:\Python26\PC -Ic:\Users\lcota\workspace\quantlib\QuantLib /Tp
QuantLib/quantlib_wrap.cpp /Fobuild\temp.win32-2.6\Release\QuantLib/quantlib_wrap.obj /GR /FD /Zm250 /EHsc /MD
cl : Command line warning D9024 : unrecognized source file type 'c:\boost\boost_1_44', object file assumed
cl : Command line warning D9027 : source file 'c:\boost\boost_1_44' ignored
quantlib_wrap.cpp
c:\Users\lcota\workspace\quantlib\QuantLib\ql/qldefines.hpp(29) : fatal error C1083: Cannot open include file: 'boost/co
nfig.hpp': No such file or directory
error: command '"c:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\BIN\cl.exe"' failed with exit status 2




Luigi Ballabio wrote
On Wed, 2010-09-15 at 05:05 -0700, newbie730 wrote:
> I have VC++ 2008 installed - how can I make sure python distutils finds it?

On my machine, distutils looks for "C:\Program Files\Microsoft Visual
Studio 9.0\VC\BIN\cl.exe" which, I think, is the default location; I
didn't have to set anything myself.
If you have it installed elsewhere, I'm afraid I can't be of much
help---you might want to search the distutils docs, or ask on some
Python list.

Luigi


--

A programming language is low-level when its programs require attention
to the irrelevant.
-- Alan Perlis



------------------------------------------------------------------------------
Start uncovering the many advantages of virtual appliances
and start using them to simplify application deployment and
accelerate your shift to cloud computing.
http://p.sf.net/sfu/novell-sfdev2dev
_______________________________________________
QuantLib-users mailing list
QuantLib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Reply | Threaded
Open this post in threaded view
|

Re: QuantLib Python Bindings - Windows

ElMariachi
OK so I am able to get past the initial error with finding boost by setting CL="/Ic:\boost\boost_1_44"

Now I get the following error:
LINK : fatal error LNK1104: cannot open file 'libboost_serialization-vc90-mt-1_44.lib'


BEGIN CONSOLE PRINTOUT
----------------------------
PS C:\Users\lcota\workspace\quantlib\Quantlib-SWIG\python> python setup.py build
running build
running build_py
running build_ext
building 'QuantLib._QuantLib' extension
c:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\BIN\cl.exe /c /nologo /Ox /MD /W3 /GS- /DNDEBUG -D__WIN32__ -DWIN3
2 -DNDEBUG -D_WINDOWS -DNOMINMAX -IC:\Python26\include -IC:\Python26\PC -Ic:\Users\lcota\workspace\quantlib\QuantLib /Tp
QuantLib/quantlib_wrap.cpp /Fobuild\temp.win32-2.6\Release\QuantLib/quantlib_wrap.obj /GR /FD /Zm250 /EHsc /MD
quantlib_wrap.cpp
using native typeof
c:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\BIN\link.exe /DLL /nologo /INCREMENTAL:NO /LIBPATH:C:\Python26\lib
s /LIBPATH:C:\Python26\PCbuild /LIBPATH:c:\Users\lcota\workspace\quantlib\QuantLib\lib /EXPORT:init_QuantLib build\temp.
win32-2.6\Release\QuantLib/quantlib_wrap.obj /OUT:build\lib.win32-2.6\QuantLib\_QuantLib.pyd /IMPLIB:build\temp.win32-2.
6\Release\QuantLib\_QuantLib.lib /MANIFESTFILE:build\temp.win32-2.6\Release\QuantLib\_QuantLib.pyd.manifest /subsystem:w
indows /machine:I386
LINK : fatal error LNK1104: cannot open file 'libboost_serialization-vc90-mt-1_44.lib'
error: command '"c:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\BIN\link.exe"' failed with exit status 1104
Reply | Threaded
Open this post in threaded view
|

Re: QuantLib Python Bindings - Windows

Luigi Ballabio

On Sep 20, 2010, at 3:42 PM, ElMariachi wrote:
> OK so I am able to get past the initial error with finding boost by  
> setting
> CL="/Ic:\boost\boost_1_44"
>
> Now I get the following error:
> LINK : fatal error LNK1104: cannot open file
> 'libboost_serialization-vc90-mt-1_44.lib'

try setting

INCLUDE=C:\boost\boost_1_44
(this should make no longer necessary to set CL)

LIB=C:\boost\boost_1_44\lib
(or wherever it is that you have libboost_*)

Luigi


------------------------------------------------------------------------------
Start uncovering the many advantages of virtual appliances
and start using them to simplify application deployment and
accelerate your shift to cloud computing.
http://p.sf.net/sfu/novell-sfdev2dev
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Reply | Threaded
Open this post in threaded view
|

Re: QuantLib Python Bindings - Windows

ElMariachi
This seems to have built the bindings, at least the build went through without errors. Now I get a similar error as I get with OSX:

>>> from QuantLib import *
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "QuantLib\__init__.py", line 19, in <module>
    from QuantLib import *
  File "QuantLib\QuantLib.py", line 24, in <module>
    _QuantLib = swig_import_helper()
  File "QuantLib\QuantLib.py", line 16, in swig_import_helper
    import _QuantLib
ImportError: No module named _QuantLib

This is *after* running python setup.py install

Luigi Ballabio wrote
On Sep 20, 2010, at 3:42 PM, ElMariachi wrote:
> OK so I am able to get past the initial error with finding boost by  
> setting
> CL="/Ic:\boost\boost_1_44"
>
> Now I get the following error:
> LINK : fatal error LNK1104: cannot open file
> 'libboost_serialization-vc90-mt-1_44.lib'

try setting

INCLUDE=C:\boost\boost_1_44
(this should make no longer necessary to set CL)

LIB=C:\boost\boost_1_44\lib
(or wherever it is that you have libboost_*)

Luigi


------------------------------------------------------------------------------
Start uncovering the many advantages of virtual appliances
and start using them to simplify application deployment and
accelerate your shift to cloud computing.
http://p.sf.net/sfu/novell-sfdev2dev
_______________________________________________
QuantLib-users mailing list
QuantLib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Reply | Threaded
Open this post in threaded view
|

Re: QuantLib Python Bindings - Windows

ElMariachi
Ignore this message - the instlal script worked correctly, I just needed to restart my shell and i am now able to import the quantlib namespace.

Thanks!

Is there any place where I can update the instructions for the windows quantlib python build? I expect (hope) to be working quite a bit with this in the near term, I'd be more than happy to contribute examples in Excel and in Python as I develop them, and/or documentation notes.


ElMariachi wrote
This seems to have built the bindings, at least the build went through without errors. Now I get a similar error as I get with OSX:

>>> from QuantLib import *
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "QuantLib\__init__.py", line 19, in <module>
    from QuantLib import *
  File "QuantLib\QuantLib.py", line 24, in <module>
    _QuantLib = swig_import_helper()
  File "QuantLib\QuantLib.py", line 16, in swig_import_helper
    import _QuantLib
ImportError: No module named _QuantLib

This is *after* running python setup.py install

Luigi Ballabio wrote
On Sep 20, 2010, at 3:42 PM, ElMariachi wrote:
> OK so I am able to get past the initial error with finding boost by  
> setting
> CL="/Ic:\boost\boost_1_44"
>
> Now I get the following error:
> LINK : fatal error LNK1104: cannot open file
> 'libboost_serialization-vc90-mt-1_44.lib'

try setting

INCLUDE=C:\boost\boost_1_44
(this should make no longer necessary to set CL)

LIB=C:\boost\boost_1_44\lib
(or wherever it is that you have libboost_*)

Luigi


------------------------------------------------------------------------------
Start uncovering the many advantages of virtual appliances
and start using them to simplify application deployment and
accelerate your shift to cloud computing.
http://p.sf.net/sfu/novell-sfdev2dev
_______________________________________________
QuantLib-users mailing list
QuantLib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Reply | Threaded
Open this post in threaded view
|

Re: QuantLib Python Bindings - Windows

Luigi Ballabio
On Mon, 2010-09-20 at 09:57 -0700, ElMariachi wrote:
> Is there any place where I can update the instructions for the windows
> quantlib python build? I expect (hope) to be working quite a bit with this
> in the near term, I'd be more than happy to contribute examples in Excel and
> in Python as I develop them, and/or documentation notes.

As for the instructions, you can post them here and I'll put them on the
site.  For examples; if you have self-contained ones, you can post them
here to be included in the distribution.  Shorter pieces of code might
go to the unofficial wiki that started recently (see the links on the
right-hand side of the QuantLib home page.)

Thanks,
        Luigi



--

Use every man after his desert, and who shall scape whipping?
-- Hamlet, Act II, scene II



------------------------------------------------------------------------------
Start uncovering the many advantages of virtual appliances
and start using them to simplify application deployment and
accelerate your shift to cloud computing.
http://p.sf.net/sfu/novell-sfdev2dev
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Reply | Threaded
Open this post in threaded view
|

Re: QuantLib Python Bindings - Windows

zhimingbaobei
My python 2.7, boost and QuantLib compiled under VS2012, can I wrap it to python under VS2008 if I do not compile them again under VS2008
Reply | Threaded
Open this post in threaded view
|

Re: QuantLib Python Bindings - Windows

Luigi Ballabio

I'm afraid you'll have to recompile. You can try though.

Luigi

On Apr 19, 2014 1:54 PM, "zhimingbaobei" <[hidden email]> wrote:
My python 2.7, boost and QuantLib compiled under VS2012, can I wrap it to
python under VS2008 if I do not compile them again under VS2008



--
View this message in context: http://quantlib.10058.n7.nabble.com/QuantLib-Python-Bindings-Windows-tp1064p15175.html
Sent from the quantlib-users mailing list archive at Nabble.com.

------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and their
applications. Written by three acclaimed leaders in the field,
this first edition is now available. Download your free book today!
http://p.sf.net/sfu/NeoTech
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users

------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and their
applications. Written by three acclaimed leaders in the field,
this first edition is now available. Download your free book today!
http://p.sf.net/sfu/NeoTech
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users