Skip to main content
gamedev.net
🔒 Locked

Compiling a Python script

Started by wgoedeck 1 reply 750+ views
Original Post
wgoedeck
wgoedeck
This is a message for Python experts. I want to create an executable program from a Python script, which I am importing "os" in the module. I've tried to use py2exe, however, when I compile, via "python setup.py py2exe," I receive an error, "ImportError: No module named os." I also receive an error: "ImportError: No module named linecache," which I didn't call. How would I include these modules, if they are required, or would another method of creating a stand-alone Python executable be advised, such as freeze.py? Thanks, Walter
Kimmi
Kimmi
Do you have add the python module path to the enviroment var PYTHONPATH? Normally you can find the basic modules like os in \lib . Make sure that this directories are set to your PYTHONPATH-variable.

For some more detailed infos take a look into this didscussion:
How to change sys.path.

Kimmi
A complicate solution may indicate a not understood problem.


[twitter]KimKulling[/twitter]
wgoedeck
wgoedeck
To Kimmi:

Thanks for your input - this worked! I created the enviroment variable PYTHONPATH, and inserted the path to the Python library. I had to also move my code out of the #def modules I made for the program to run as an executable.

Thanks,
Walter

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.