Question

Hi I have created an application that allows end user python scripting. The main portion of the application is written in python, this I have compiled away to an exe using pyinstaller this is fine that part of the application works just fine.

This application then calls a DLL that embeds python, this then calls some end user python scripts. There has been no problem with this when I've been testing it but once I have compiled the program using pyinstaller the DLL prints the error "ImportError: No module named site".

I'm on Windows with Python 2.7.

From what I can tell from other posts this is a problem with the PYTHONHOME PYTHONPATH environment variables, which I'm sure I can set from within the DLL. However considering that the end user may not have Python installed on their computer do I need to provide the full Python 2.7 installation with my program changing the PYTHONHOME and PYTHONPATH to that installation? Is this the correct way to go about this?

Was it helpful?

Solution 2

The only way I got this to work was to distribute some of python 2.7 with the application namely the Lib and DLLs directories under a directory Python27 in the same folder as the executable that has embedded python.

This overcame the problem that the user may not have python installed and meant that they will be able to add modules of their own to the python "home" local to the application. This is basically what I ended up doing to get this how I want it.

https://stackoverflow.com/a/2970407/722634

OTHER TIPS

You are correct. End user should be able to run your exe even if python is not there on his system. Instead, when end-user runs your exe, your exe should make calls to the pyx,pyo files. And, those files will be packaged by the pyinstaller. Also, you need to make sure that you point the path to those pyx,pyo files

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top