PyImport_Import fails (returns NULL)
I have resolved this issue by setting PYTHONPATH to pwd
. Also module name (without .py) should be set for argv[1].
Thank you!
I ran into this issue also after struggling for a while.After searching the web I found that is was a system path issue. After adding the two lines after Py_Initialize(); it worked.
OS: Windows 7, Compiler: Embarcadero C++ Builder XE6, Python: Version 2.7
Reference: C++ With Python
Py_Initialize();
PyRun_SimpleString("import sys");
PyRun_SimpleString("sys.path.append(\"C:\\Python27\")");