How to import a boost::python dll in windows?
I'm trying to port some research code that uses boost::python to expose a library to python to windows, but I'm having trouble importing the dll into python. I'm compiling using msvc 2005 and using python 2.5, but when I try to import the module I get this: Traceback (most recent call last): File "main.py", line 1, in <module> import object File "c:\code\sge\code\scripts\object.py", line 1, in <module> import sge ImportError: No module named sge My module is named sge and I'm compiling to sge.dll. Is there some obvious reason why python wouldn't be able to find my dll? When I compile on linux into an so this code works fine. -- View this message in context: http://www.nabble.com/How-to-import-a-boost%3A%3Apython-dll-in-windows--tf32... Sent from the Python - c++-sig mailing list archive at Nabble.com.
On 2/14/07, ichijoji <ichijoji@gmail.com> wrote:
I'm trying to port some research code that uses boost::python to expose a library to python to windows, but I'm having trouble importing the dll into python. I'm compiling using msvc 2005 and using python 2.5, but when I try to import the module I get this:
Traceback (most recent call last): File "main.py", line 1, in <module> import object File "c:\code\sge\code\scripts\object.py", line 1, in <module> import sge ImportError: No module named sge
My module is named sge and I'm compiling to sge.dll. Is there some obvious reason why python wouldn't be able to find my dll? When I compile on linux into an so this code works fine.
You are using Python2.5. In this version of Python you have to have file extension to be "pyd" - sge.pyd -- Roman Yakovenko C++ Python language binding http://www.language-binding.net/
Hi, I am having a similar problem as the o.p. I was trying to build Python wrappers for the hello_ext project given in the boost tutorial using CMake instead of bjam using the instructions as per http://mail.python.org/pipermail/cplusplus-sig/2007-June/012247.html The setup is Boost 1.47.0, Python 2.7, Windows 7 x64, MSVC 2008 (9.0) x64. After doing CMake and MSVC - it produces a hello_ext.dll. Even if i rename this to hello_ext.pyd, Python throws the following error. Any suggestions / ideas ? Thanks, -fj In [12]: ls Directory of D:\software\boost\boost-source\libs\python\example\tutorial\build\Release 05-Aug-11 16:36 <DIR> . 05-Aug-11 16:36 <DIR> .. 05-Aug-11 16:34 732 hello_ext.exp 05-Aug-11 16:34 945,152 hello_ext.idb 05-Aug-11 16:34 1,750 hello_ext.lib 05-Aug-11 16:34 11,264 hello_ext.pyd 4 File(s) 958,898 bytes 2 Dir(s) 370,089,795,584 bytes free In [13]: import hello_ext --------------------------------------------------------------------------- ImportError Traceback (most recent call last) D:\software\boost\boost-source\libs\python\example\tutorial\build\Release\<ipython-input-13-18c4d654 8768> in <module>() ----> 1 import hello_ext ImportError: DLL load failed: The specified module could not be found. -- View this message in context: http://boost.2283326.n4.nabble.com/C-sig-How-to-import-a-boost-python-dll-in... Sent from the Python - c++-sig mailing list archive at Nabble.com.
I know next-to-nothing about linking dynamic libraries in Windows, but if I saw a message like that in Linux, I'd check my dynamic linker path to ensure the Boost.Python shared library is in it; any Python module you build is linked against against that library. If the dynamic linker can't find the boost_python library when it tries to load your module, it's very likely that it would complain about your module not being found, because it was unable to resolve some symbols in it. Hopefully a Windows expert on the list will chime in, but I gather the list is rather short on those. HTH Jim Bosch On 08/05/2011 01:43 PM, fjanoos wrote:
Hi, I am having a similar problem as the o.p.
I was trying to build Python wrappers for the hello_ext project given in the boost tutorial using CMake instead of bjam using the instructions as per http://mail.python.org/pipermail/cplusplus-sig/2007-June/012247.html
The setup is Boost 1.47.0, Python 2.7, Windows 7 x64, MSVC 2008 (9.0) x64.
After doing CMake and MSVC - it produces a hello_ext.dll. Even if i rename this to hello_ext.pyd, Python throws the following error. Any suggestions / ideas ?
Thanks, -fj
In [12]: ls
Directory of D:\software\boost\boost-source\libs\python\example\tutorial\build\Release
05-Aug-11 16:36<DIR> . 05-Aug-11 16:36<DIR> .. 05-Aug-11 16:34 732 hello_ext.exp 05-Aug-11 16:34 945,152 hello_ext.idb 05-Aug-11 16:34 1,750 hello_ext.lib 05-Aug-11 16:34 11,264 hello_ext.pyd 4 File(s) 958,898 bytes 2 Dir(s) 370,089,795,584 bytes free
In [13]: import hello_ext --------------------------------------------------------------------------- ImportError Traceback (most recent call last) D:\software\boost\boost-source\libs\python\example\tutorial\build\Release\<ipython-input-13-18c4d654 8768> in<module>() ----> 1 import hello_ext
ImportError: DLL load failed: The specified module could not be found.
-- View this message in context: http://boost.2283326.n4.nabble.com/C-sig-How-to-import-a-boost-python-dll-in... Sent from the Python - c++-sig mailing list archive at Nabble.com. _______________________________________________ Cplusplus-sig mailing list Cplusplus-sig@python.org http://mail.python.org/mailman/listinfo/cplusplus-sig
Hi, The problem was with using the dynamic version of the windows libraries (/MD) - after changing the project settings to use the static libraries (/MT) this worked out just fine. thanks, -firdaus ________________________________ From: Jim Bosch-2 [via Boost] <ml-node+3722336-340765095-257412@n4.nabble.com> To: fjanoos <fjanoos@yahoo.com> Sent: Friday, August 5, 2011 5:35 PM Subject: Re: How to import a boost::python dll in windows? I know next-to-nothing about linking dynamic libraries in Windows, but if I saw a message like that in Linux, I'd check my dynamic linker path to ensure the Boost.Python shared library is in it; any Python module you build is linked against against that library. If the dynamic linker can't find the boost_python library when it tries to load your module, it's very likely that it would complain about your module not being found, because it was unable to resolve some symbols in it. Hopefully a Windows expert on the list will chime in, but I gather the list is rather short on those. HTH Jim Bosch On 08/05/2011 01:43 PM, fjanoos wrote:
Hi, I am having a similar problem as the o.p.
I was trying to build Python wrappers for the hello_ext project given in the boost tutorial using CMake instead of bjam using the instructions as per http://mail.python.org/pipermail/cplusplus-sig/2007-June/012247.html
The setup is Boost 1.47.0, Python 2.7, Windows 7 x64, MSVC 2008 (9.0) x64.
After doing CMake and MSVC - it produces a hello_ext.dll. Even if i rename this to hello_ext.pyd, Python throws the following error. Any suggestions / ideas ?
Thanks, -fj
In [12]: ls
Directory of D:\software\boost\boost-source\libs\python\example\tutorial\build\Release
05-Aug-11 16:36<DIR> . 05-Aug-11 16:36<DIR> .. 05-Aug-11 16:34 732 hello_ext.exp 05-Aug-11 16:34 945,152 hello_ext.idb 05-Aug-11 16:34 1,750 hello_ext.lib 05-Aug-11 16:34 11,264 hello_ext.pyd 4 File(s) 958,898 bytes 2 Dir(s) 370,089,795,584 bytes free
In [13]: import hello_ext --------------------------------------------------------------------------- ImportError Traceback (most recent call last) D:\software\boost\boost-source\libs\python\example\tutorial\build\Release\<ipython-input-13-18c4d654 8768> in<module>() ----> 1 import hello_ext
ImportError: DLL load failed: The specified module could not be found.
-- View this message in context: http://boost.2283326.n4.nabble.com/C-sig-How-to-import-a-boost-python-dll-in... Sent from the Python - c++-sig mailing list archive at Nabble.com. _______________________________________________ Cplusplus-sig mailing list [hidden email] http://mail.python.org/mailman/listinfo/cplusplus-sig
Cplusplus-sig mailing list [hidden email] http://mail.python.org/mailman/listinfo/cplusplus-sig ________________________________ If you reply to this email, your message will be added to the discussion below:http://boost.2283326.n4.nabble.com/C-sig-How-to-import-a-boost-python-dll-in... To unsubscribe from [C++-sig]How to import a boost::python dll in windows?, click here. -- View this message in context: http://boost.2283326.n4.nabble.com/C-sig-How-to-import-a-boost-python-dll-in... Sent from the Python - c++-sig mailing list archive at Nabble.com.
participants (4)
-
fjanoos -
ichijoji -
Jim Bosch -
Roman Yakovenko