Note that there are some explanatory texts on larger screens.

plurals
  1. POUnable to get python embedded to work with zip'd library
    text
    copied!<p>I'm trying to embed python, and provide the dll and a zip of the python libraries and not use any installed python. That is, if a user doesn't have python, I want my code to work using the provided dll/zip.</p> <p>This <a href="https://stackoverflow.com/questions/1387906/c-with-python-embedding-crash-if-python-not-installed">post</a> seems to describe the process, except it isn't working for me.</p> <p>If I run the following, my code will run as long as I have Python27.dll and a <em>folder</em> named Python27 that contains the DLL and Lib folders.</p> <pre><code>Py_SetProgramName(argv[0]); /* optional but recommended */ Py_SetPythonHome("Python27"); Py_Initialize(); </code></pre> <p>If I remove the Python27 folder, the code fails - so I am pulling in the local copy, not any installed python.</p> <p>However, if I zip the local Python27 folder, the code stops running, giving "ImportError: No module named site".</p> <p><a href="http://www.python.org/dev/peps/pep-0273/" rel="nofollow noreferrer">PEP273</a> makes it sound like this should just work, but everything I've tried has failed.</p> <p>Can anyone shed light on how to get embedded python to run from a zip file?</p> <p>Given that there are related questions that have gone unanswered, I think it would be helpful if people would add a comment if they have successfully gotten reading from a zip file working, even if they aren't sure what I might need to fix. </p> <p>That would at least help me understand if I should keep looking for an answer! </p> <p><strong>Update</strong>: No matter what I try (even with LoadLibrary as suggested), I can run my program from a fully unzipped directory. Any time I remove the directory with DLLs/* and Lib/* and put in Python27.zip instead, I just get </p> <pre><code>ImportError: No module named site </code></pre>
 

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