Jump to content

Welcome to Geeks to Go - Register now for FREE

Need help with your computer or device? Want to learn new tech skills? You're in the right place!
Geeks to Go is a friendly community of tech experts who can solve any problem you have. Just create a free account and post your question. Our volunteers will reply quickly and guide you through the steps. Don't let tech troubles stop you. Join Geeks to Go now and get the support you need!

How it Works Create Account
Photo

py2exe windows xp


  • Please log in to reply

#1
TaNkZ101

TaNkZ101

    Member

  • Member
  • PipPipPip
  • 327 posts
step-by-step how to use py2exe on windows xp to create an executable from a .py?
  • 0

Advertisements


#2
Swandog46

Swandog46

    Malware Expert

  • Member
  • PipPipPipPip
  • 1,026 posts
  • MVP
Did you READ the documentation?

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"].


  • 0

#3
TaNkZ101

TaNkZ101

    Member

  • Topic Starter
  • Member
  • PipPipPip
  • 327 posts
running setup.py will open a command prompt, and close it after less than 1 second. they don't have that in there.
  • 0

#4
TaNkZ101

TaNkZ101

    Member

  • Topic Starter
  • Member
  • PipPipPip
  • 327 posts
if i use the command promt to open it, i get 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>
  • 0

#5
Swandog46

Swandog46

    Malware Expert

  • Member
  • PipPipPipPip
  • 1,026 posts
  • MVP
You didn't follow their directions!

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
  • 0

#6
TaNkZ101

TaNkZ101

    Member

  • Topic Starter
  • Member
  • PipPipPip
  • 327 posts

running setup.py will open a command prompt, and close it after less than 1 second.

maybe you didn't understand.

Opening (double-clicking) setup.py will open a command prompt, and close it after less than 1 second.
  • 0

#7
TaNkZ101

TaNkZ101

    Member

  • Topic Starter
  • Member
  • PipPipPip
  • 327 posts
step-by-step please.
i am very close to telling py2exe to do you-know-what

the documentation is written atrociously.

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.

can you say sentence fragment?
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.

  • 0

#8
Swandog46

Swandog46

    Malware Expert

  • Member
  • PipPipPipPip
  • 1,026 posts
  • MVP
Running setup.py without any arguments will cause it to close immediately, yes.

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

  • 0

#9
TaNkZ101

TaNkZ101

    Member

  • Topic Starter
  • Member
  • PipPipPip
  • 327 posts
wow would u believe me if i said it worked? finally! yipee! so for it to run on xp, i need everything except the "w9xpopen.exe"? are any of the other files associated ONLy with w9xpopen.exe so that i can omit them as well? this is so cool :whistling:
  • 0

#10
Swandog46

Swandog46

    Malware Expert

  • Member
  • PipPipPipPip
  • 1,026 posts
  • MVP
No, you'll need them all. See:
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.
  • 0

#11
TaNkZ101

TaNkZ101

    Member

  • Topic Starter
  • Member
  • PipPipPip
  • 327 posts
what? the quiz.exe accesses the .zip file? i didn't know that was possible

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.

  • 0

#12
Swandog46

Swandog46

    Malware Expert

  • Member
  • PipPipPipPip
  • 1,026 posts
  • MVP

what? the quiz.exe accesses the .zip file? i didn't know that was possible

Sure, why not?

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.

Yup, and that's a good reason to do it! Python is a simple and powerful language, and a good choice for a beginner. :whistling:
  • 0

#13
TaNkZ101

TaNkZ101

    Member

  • Topic Starter
  • Member
  • PipPipPip
  • 327 posts

what? the quiz.exe accesses the .zip file? i didn't know that was possible

Sure, why not?

don't u need winzip or a similiar program to use the files in a .zip?
  • 0

#14
Swandog46

Swandog46

    Malware Expert

  • Member
  • PipPipPipPip
  • 1,026 posts
  • MVP
How does WinZip work? A zip file is just a file format like any other; at bottom it is just a string of 1's and 0's and can be accessed or modified like any other file. Any programmer that knows what the zip file format looks like could in theory implement zip file functionality. Or, there are publicly-available libraries to do it. See:
http://www.zlib.net/
  • 0






Similar Topics

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

As Featured On:

Microsoft Yahoo BBC MSN PC Magazine Washington Post HP