[Boost.Python] tutorial python extension fails on import with ImportError: No module named hello_ext

View: New views
1 Messages — Rating Filter:   Alert me  

[Boost.Python] tutorial python extension fails on import with ImportError: No module named hello_ext

by Charles Lentz :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Some parts of this message have been removed. Learn more about Nabble's security policy.

Hey all,

 

When using boost_1_38_0\libs\python\example\tutorial, I try to import the extension that is created (hello_ext) but get the exception, ImportError: No module named hello_ext

 

Here’s some details that might be needed:

 

OS: Windows Vista

Boost version: 1.38.0

Bjam version: 3.1.17

Python version: 2.6.2

 

My user-config.jam looks like this:

 

#  MSVC configuration

using msvc : 9.0 ;

 

#  Python configuration

using python

  : 2.6                                                                                                                      #version

  : C:/Python26                                                                                                  #location

  : C:/projects/external/python/Python-2.6.2/Include                    #includes

  : C:/projects/external/python/Python-2.6.2/Lib                             #libraries

  ;

 

 

I am working with the tutorial example located here: boost_1_38_0\libs\python\example\tutorial.  When I run Bjam after I cd to this directory, this tutorial example says that it passes all the tests and I can check the output in the resulting files within the hello.test directory.  That's all well and good that the test can get this extension module to work, but I want to be able to import it myself in a python session or python file.  That way I can see it work and then move on to creating my own extensions.

 

I modify Jamroot so that the last few lines where it creates tests are commented out.  When I run bjam again, hello_ext.pyd remains (previously it was being created, used for the test, and then deleted).  I try to run hello.py (which is the script that the test uses) from IDLE (which comes with the installation of python) and it throws an exception for my import statement

 

Traceback (most recent call last):

  File "C:\Users\Charles\Desktop\boost_1_38_0\boost_1_38_0\libs\python\example\tutorial\hello.py", line 6, in <module>

    import hello_ext

ImportError: No module named hello_ext

 

Hrmm.  Okay.  So I move the hello.py file into the same directory as the hello_ext.pyd file.  Run it again using IDLE, still get the exception

 

Traceback (most recent call last):

  File "C:\Users\Charles\Desktop\boost_1_38_0\boost_1_38_0\libs\python\example\tutorial\bin\msvc-9.0\debug\threading-multi\hello.py", line 6, in <module>

    import hello_ext

ImportError: No module named hello_ext

 

 

So I guess I need some help here.  I want to be able to create an extension module and then import it in a script.  This is what I was led to believe I could do, but I do not see how.  I have tried to provide all information that I think is necessary.  Any help is greatly appreciated.



__________ Information from ESET NOD32 Antivirus, version of virus signature database 4593 (20091110) __________

The message was checked by ESET NOD32 Antivirus.

http://www.eset.com

_______________________________________________
Cplusplus-sig mailing list
Cplusplus-sig@...
http://mail.python.org/mailman/listinfo/cplusplus-sig