I am working on a simple (?) Embedded Python project. I have my own package that was installed in the site packages with setup.py installed, for example:
in C: \ Python27 \ Lib \ site-packages \:
mypackage\
__init__.py
subpackage\
__init__.py
subpackage.py
....
mymodule.py
code>
Just making some simple inline calls, I get some behavior that doesn't match what I get in the cmd window that Python is running on. In particular:
PyRun_SimpleString("import mypackage")
PyRun_SimpleString("from mypackage import subpackage")
PyRun_SimpleString("from mypackage import mymodule")
... whereas all of them work fine in the CMD window (there is no ImportError, and I can get the expected results, for example, dir(mymodule)
, , Py_Initialize(), , cmd, sys.path... SO, ' sys.path:
PyRun_SimpleString("import sys\nsys.path.insert(0,'')") , , -1. sys.path 'C:\Python27\Lib\site-packages\mypackage', 'mymodule' (mymodule.py).
SO , , .
__import__('mypackage',globals(), locals(), fromlist=['mymodule'])
__import__('mypackage.mymodule',globals(), locals(), fromlist=['mymodule'])
PyImport_ImportModuleEx PyRun_SimpleString, , " mypackage import mymodule".
: MacOS/Python 2.7. Windows, .
, ?
UPDATE: : "subpackage.py" ( "utilites.pyd" ). ".py" , .