Python newbie trying to embed in C++

Marwan LarrxX at free.fr
Wed Feb 27 09:51:10 CET 2013


Hello all,

I'm new to Python and just starting to learn it. For he needs of my 
project, I need to call some specific methods in Python scripts from C++.

For now, I just compiled the example in the Python documentation about 
Pure Embedding to try it out ( 
http://docs.python.org/2/extending/embedding.html#pure-embedding ).

I'm trying to test it on an extremely simple script called test.py which 
contains the following:

def testPY( value ):
    print('You input ', value )

  def Hello():
	print('Hello')


When I run the generated exe, I get errors about the functions not 
existing...

TestPython.exe test Hello
AttributeError: 'module' object has no attribute 'Hello'
Cannot find function "Hello"


My Python version is 2.7.3 because that's the version used in the module 
we need to access. And I'm using VS2010 SP1 for compiling my C++ because 
that's the version used to generate our DLLs and EXEs.

Could anyone tell me why this is happening?

And I'd appreciate it if you could give me pointers to how to easily 
call Python from C++.

Thanks in advance for your help,

Marwan



More information about the Python-list mailing list