Compiling a Python script

Started by
1 comment, last by wgoedeck 14 years, 8 months ago
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
Advertisement
Do you have add the python module path to the enviroment var PYTHONPATH? Normally you can find the basic modules like os in <Home_of_your_python_installation>\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]
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

This topic is closed to new replies.

Advertisement