Note that there are some explanatory texts on larger screens.

plurals
  1. POload pyd files from a zip from embedded python
    text
    copied!<p>I can load Python modules (.py, .pyc, .pyd) from a zip file by calling "import some_module" from a Python interpreter only after sys.path has been extended to include the zip file and only after I have run</p> <pre><code>import zipextimporter zipextimporter.install() </code></pre> <p>The latter is required for .pyd modules.</p> <p>I can also load Python .py and .pyc modules from Python embedded in C++. However, in order to also load .pyd modules from embedded Python I added</p> <pre><code>PyRun_SimpleString("import zipextimporter"); </code></pre> <p>The C++ exe runs beyond this line without error. But the next command</p> <pre><code>PyRun_SimpleString("zipextimporter.install()"); </code></pre> <p>gives me this error:</p> <p><img src="https://i.stack.imgur.com/3iYeR.png" alt="enter image description here"></p> <p>Why does zipextimporter.install() crash when Python is embedded?</p> <p>How can I solve this? </p> <p>Does it perhaps have to do with the way the C++ code is compiled? I use g++:</p> <p><code>g++ embed-simple.cpp -IE:\Python27\include -LE:\Python27\libs -lpython27 -o embed-simple</code></p> <p>I saw a link <a href="https://stackoverflow.com/questions/3402252/how-to-link-against-msvcr90-dll-with-mingw-gcc">How to link against msvcr90.dll with mingw gcc?</a></p> <p>Could that provide a solution? If yes, how should I adjust it, gcc-->g++, since I am running C++ code, not C.</p> <p>I am running Python 2.7.2 on WinXP.</p> <p>I don't get the runtime error after a clean install of Python 2.7.2, just this:</p> <blockquote> <p>Import Error: No module named....</p> </blockquote> <p>Would it matter the way the embedding C++ script is compiled? I used g++. I also compiled with the Intel compiler, but that gave the same runtime error. Perhaps I should try MS Visual C++. </p> <p>Or use ctypes to import the pyd?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload