[C++-sig] boost/python tutorial

Scott VanSickle Scott.VanSickle at CanfieldSci.com
Tue Nov 20 15:55:35 CET 2007


You need to copy the generated pyd and lib files into a folder that corresponds to the name of your Python module under your Python root folder.  Note that the pyd is the DLL, the lib is the DLL's import library.  If you don't use namespaces, I think that the pyd and lib should be copied directly into your Python root folder.

Create an __init__.py file in the module folder that looks something like this

#============
import sys

sys.path.append('..\..')

# this brings in the DLL (pyd)
from _hello_ext import *

#============

You should then be able to import your hello_ext module in any of your Python code.

Scott V


From: c++-sig-bounces at python.org [mailto:c++-sig-bounces at python.org] On Behalf Of Nguyen Xuan Son
Sent: Tuesday, November 20, 2007 6:06 AM
To: c++-sig at python.org
Subject: [C++-sig] boost/python tutorial

Hi
I run the command line to build the \boost\libs\python\example\tutorial

>bjam -sPYTHON_ROOT=C:/Python24 -sPYTHON_VERSION=2.4  -sTOOLS=vc8

I see that everything run correctly and I check the folder
\boost\libs\python\example\tutorial\bin\hello.test\msvc-8.0\debug\threading-multi

and the output told me everything is OK. But I find no where the DLL, and I could not load the extension from the python command line:
>>> import hello_ext

Traceback (most recent call last):
  File "<pyshell#0>", line 1, in -toplevel-
    import hello_ext
ImportError: No module named hello_ext

Can someone help me out of this? I really confused.

Son



More information about the Cplusplus-sig mailing list