importing boost-python module in python on windows

Hi, I have created an extension boost python module for C++ class, successfully using Visual Studio 2009, and get a shared library(.dll) as output. However I am having trouble importing this module in my python code. I have explicitly tried importing the dll as resource in an Eclipse PyDev project, and also set in windows PATH environment variable, the location for this dll. With the PATH set, I also tried import from the python shell, but no success. Can someone describe what is the process to import boost_python_modules in python on windows. Thanks, Seema

Seema Jaisinghani wrote:
I have created an extension boost python module for C++ class, successfully using Visual Studio 2009, and get a shared library(.dll) as output.
However I am having trouble importing this module in my python code. I have explicitly tried importing the dll as resource in an Eclipse PyDev project, and also set in windows PATH environment variable, the location for this dll. With the PATH set, I also tried import from the python shell, but no success.
Can someone describe what is the process to import boost_python_modules in python on windows.
Change your shared library's filename extension from .dll to .pyd. As of Python 2.5, the Python interpreter stopped accepting .dll as a valid extension module filename: http://www.python.org/doc/2.5.4/whatsnew/ports.html#SECTION00015100000000000... "Windows: .dll is no longer supported as a filename extension for extension modules. .pyd is now the only filename extension that will be searched for."

Thanks for the response. Simply changing the name of the extension .dll to .pyd does not help. ImportError: DLL load failed: The specified module could not be found. It is not a path problem, as another module in the same location can be imported correctly. I am building the boost_extension_module in Visual Studio IDE. Is there a way to output a pyd directly, instead of dll? What else is required to let Python know about boost_python libs? Thanks. Change your shared library's filename extension from .dll to .pyd. As of Python 2.5, the Python interpreter stopped accepting .dll as a valid extension module filename: http://www.python.org/doc/2.5.4/whatsnew/ports.html#SECTION00015100000000000... "Windows: .dll is no longer supported as a filename extension for extension modules. .pyd is now the only filename extension that will be searched for." _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users

Seema Jaisinghani wrote:
Thanks for the response. Simply changing the name of the extension .dll to .pyd does not help.
ImportError: DLL load failed: The specified module could not be found.
It is not a path problem, as another module in the same location can be imported correctly.
That would have been my next suggestion. What's the full filename of the other module? Is it a Python module or another extension module? Does your extension module depend on any other .dlls (not Python extensions)? Where are they stored? In a previous product, we had to set both PYTHONPATH and PATH: PYTHONPATH to direct the interpreter to our extension modules, PATH to direct the OS to the DLLs on which our extension modules depended.
I am building the boost_extension_module in Visual Studio IDE. Is there a way to output a pyd directly, instead of dll?
I'm sure there is, but I don't have a Windows machine handy just now. Poke around in the project's Properties panes.
What else is required to let Python know about boost_python libs?
That should be all. The Python interpreter knows nothing about Boost.Python. The Boost.Python library simply automates construction of the interface data required for any Python extension module. The classic approach was to hand-code it. If you were having trouble with that interface data, you'd get an entirely different error message.

Hi, I found that it was a version mismatch problem. I was using Python 2.6 and boost 1.37. Even though the boost-python project compiled with python 2.6 and the module was created without any errors. When I used the module within python 2.6, it was looking for python25.dll Rebuilding with 2.5 fixed the problem. Thanks, Seema -----Original Message----- From: boost-users-bounces@lists.boost.org [mailto:boost-users-bounces@lists.boost.org] On Behalf Of Nat Goodspeed Sent: Monday, June 15, 2009 7:41 AM To: boost-users@lists.boost.org Subject: Re: [Boost-users] importing boost-python module in python on windows Seema Jaisinghani wrote:
Thanks for the response. Simply changing the name of the extension .dll to .pyd does not help.
ImportError: DLL load failed: The specified module could not be found.
It is not a path problem, as another module in the same location can be imported correctly.
That would have been my next suggestion. What's the full filename of the other module? Is it a Python module or another extension module? Does your extension module depend on any other .dlls (not Python extensions)? Where are they stored? In a previous product, we had to set both PYTHONPATH and PATH: PYTHONPATH to direct the interpreter to our extension modules, PATH to direct the OS to the DLLs on which our extension modules depended.
I am building the boost_extension_module in Visual Studio IDE. Is there a way to output a pyd directly, instead of dll?
I'm sure there is, but I don't have a Windows machine handy just now. Poke around in the project's Properties panes.
What else is required to let Python know about boost_python libs?
That should be all. The Python interpreter knows nothing about Boost.Python. The Boost.Python library simply automates construction of the interface data required for any Python extension module. The classic approach was to hand-code it. If you were having trouble with that interface data, you'd get an entirely different error message. _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
participants (2)
-
Nat Goodspeed
-
Seema Jaisinghani