py2exe windows xp
#1
Posted 28 July 2006 - 03:44 AM
#2
Posted 28 July 2006 - 07:09 AM
Using py2exe
Assuming you have written a python script myscript.py which you want to convert into an executable windows program, able to run on systems without a python installation. If you don't already have written a distutils setup-script, write one, and insert the statement import py2exe before the call to the setup function:
# setup.py
from distutils.core import setup
import py2exe
setup(console=["myscript.py"])
Running
python setup.py py2exe --help
will display all available command-line flags to the py2exe command.
Now you can call the setup script like in this way:
python setup.py py2exe
and a subdirectory dist will be created, containing the files myscript.exe, python23.dll, and library.zip. If your script uses compiled C extension modules, they will be copied here as well, also all dlls needed at runtime (except the system dlls).
These files include everything that is needed for your program, and you should distribute the whole directory contents.
The above setup script creates a console program, if you want a GUI program without the console window, simply replace console=["myscript.py"] with windows=["myscript.py"].
#3
Posted 28 July 2006 - 10:17 AM
#4
Posted 28 July 2006 - 10:20 AM
Microsoft Windows XP [Version 5.1.2600]
© Copyright 1985-2001 Microsoft Corp.
C:\Documents and Settings\BERISLAV>C:\hrv\python\quiz\setup.py
usage: setup.py [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
or: setup.py --help [cmd1 cmd2 ...]
or: setup.py --help-commands
or: setup.py cmd --help
error: no commands supplied
C:\Documents and Settings\BERISLAV>
#5
Posted 28 July 2006 - 10:54 AM
You put this in setup.py?
# setup.py from distutils.core import setup import py2exe setup(console=["myscript.py"])
Now you can call the setup script like in this way:
python setup.py py2exe
and a subdirectory dist will be created, containing the files myscript.exe, python23.dll, and library.zip. If your script uses compiled C extension modules, they will be copied here as well, also all dlls needed at runtime (except the system dlls).
Go to the command prompt and run:
python setup.py py2exe
#6
Posted 28 July 2006 - 12:20 PM
maybe you didn't understand.running setup.py will open a command prompt, and close it after less than 1 second.
Opening (double-clicking) setup.py will open a command prompt, and close it after less than 1 second.
#7
Posted 28 July 2006 - 12:21 PM
i am very close to telling py2exe to do you-know-what
the documentation is written atrociously.
can you say sentence fragment?Assuming you have written a python script myscript.py which you want to convert into an executable windows program, able to run on systems without a python installation.
2) it does not say what to run. it says to run
"python setup.py py2exe --help"
i do not have a file named "python setup.py py2exe --help".
Edited by TaNkZ101, 28 July 2006 - 12:30 PM.
#8
Posted 28 July 2006 - 01:11 PM
Go back to the command prompt where you got this:
Microsoft Windows XP [Version 5.1.2600]
© Copyright 1985-2001 Microsoft Corp.
C:\Documents and Settings\BERISLAV>C:\hrv\python\quiz\setup.py
usage: setup.py [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
or: setup.py --help [cmd1 cmd2 ...]
or: setup.py --help-commands
or: setup.py cmd --help
error: no commands supplied
C:\Documents and Settings\BERISLAV>
at the command prompt type:
cd c:\hrv\python\quiz
python setup.py py2exe
#9
Posted 28 July 2006 - 03:10 PM
#10
Posted 28 July 2006 - 04:27 PM
http://www.codecomme...-12-350825.html
python24.dll is the implementation of the Python API, and the zip file contains the standard python modules you are importing into your code.
Nobody said this way of programming was efficient! If efficiency is your goal you would be using C, not Python.
#11
Posted 29 July 2006 - 02:52 AM
oh and I'm not complaining about the file/folder size, i knew it would be many times larger than just the .py.
i want to learn python so i can learn the basics of programming well, to learn how to think, to learn how to put together small programs.
Edited by TaNkZ101, 29 July 2006 - 02:59 AM.
#12
Posted 29 July 2006 - 07:42 AM
Sure, why not?what? the quiz.exe accesses the .zip file? i didn't know that was possible
Yup, and that's a good reason to do it! Python is a simple and powerful language, and a good choice for a beginner.oh and I'm not complaining about the file/folder size, i knew it would be many times larger than just the .py.
i want to learn python so i can learn the basics of programming well, to learn how to think, to learn how to put together small programs.
#13
Posted 29 July 2006 - 11:41 AM
don't u need winzip or a similiar program to use the files in a .zip?Sure, why not?what? the quiz.exe accesses the .zip file? i didn't know that was possible
#14
Posted 29 July 2006 - 02:27 PM
http://www.zlib.net/
Similar Topics
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users