Why does this "out-import" not work with PyRun_SimpleString?

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") //Success (return == 0)
PyRun_SimpleString("from mypackage import subpackage") //Success
PyRun_SimpleString("from mypackage import mymodule") //Fail (return == -1)

... 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" , .

+3
1

...

, utilities.pyd, Dependency Walker , MSVCR90.DLL( ). DLL , , , .

(Vista ) . MSVCR , <dependency> .pyd MSVCR90.DLL, Python27.DLL, \Windows\WinSxS ( ).

. , python setup.py mypackage, : -)

0

All Articles