Sunday, 25 August 2013

Unable to get python embedded to work with zip'd library

Unable to get python embedded to work with zip'd library

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.
This post seems to describe the process, except it isn't working for me.
If I run the following, my code will run as long as I have Python27.dll
and a folder named Python27 that contains the DLL and Lib folders.
Py_SetProgramName(argv[0]); /* optional but recommended */
Py_SetPythonHome("Python27");
Py_Initialize();
If I remove the Python27 folder, the code fails - so I am pulling in the
local copy, not any installed python.
However, if I zip the local Python27 folder, the code stops running,
giving "ImportError: No module named site".
PEP273 makes it sound like this should just work, but everything I've
tried has failed.
Can anyone shed light on how to get embedded python to run from a zip file?

No comments:

Post a Comment