Python Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesPython Programming
Receive the tools necessary to be the rock star of your field. Our 12-month program teaches you the evolving world of multi-channel marketing as well as the complex issues and opportunities found in the industry.

ASP Free and Iron Speed Designer are giving away $5,500+ in FREE licenses. Iron Speed's RAD CASE toolset can save up to 80% of your coding time. One free license per week, one perpetual license per month!
Download and Activate to enter!

Web development can be a daunting task, even for specialists. There is a lot of information to absorb and a lot of technologies to learn in order to manage a superior website. When trying to learn the ropes, developers need a reliable source to introduce new ideas that can be easily implemented. When working on large projects, even web veterans may run into a technology or an aspect of a technology that they are unfamiliar with.

Learn More!


Download to Enter
| Contest Rules

Tutorials | Forums

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old December 9th, 2004, 04:26 AM
Grim Archon's Avatar
Grim Archon Grim Archon is offline
Mini me.
Dev Shed Novice (500 - 999 posts)
 
Join Date: Nov 2003
Location: Cambridge, UK
Posts: 783 Grim Archon User rank is Corporal (100 - 500 Reputation Level)Grim Archon User rank is Corporal (100 - 500 Reputation Level)Grim Archon User rank is Corporal (100 - 500 Reputation Level)Grim Archon User rank is Corporal (100 - 500 Reputation Level)  Folding Points: 1488 Folding Title: Novice Folder
Time spent in forums: 3 Days 2 h 15 m 57 sec
Reputation Power: 11
Send a message via MSN to Grim Archon
PY2EXE step-by-step guide

People seem to have lots of problems with py2exe, I hope this helps:
py2exe guide

As this is fresh out off the press there maybe bugs - so any comments are appreciated.

grim
Comments on this post
shearn89 agrees: excellent!
pabloj agrees!
BeetleJuice agrees: Good use of the KISS principle.
DomSau agrees: not bad
TextParser agrees: good one
__________________
*** Experimental Python Markup CGI V2 ***

Reply With Quote
  #2  
Old December 9th, 2004, 05:15 AM
NewPythoner NewPythoner is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2004
Location: Bombay, India
Posts: 159 NewPythoner User rank is Corporal (100 - 500 Reputation Level)NewPythoner User rank is Corporal (100 - 500 Reputation Level)NewPythoner User rank is Corporal (100 - 500 Reputation Level)NewPythoner User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 43 m 45 sec
Reputation Power: 10
Send a message via Yahoo to NewPythoner
The step-by-step guide was very clear and simply put!

Good one!!!!

Subha

Reply With Quote
  #3  
Old December 9th, 2004, 03:03 PM
netytan's Avatar
netytan netytan is offline
Hello World :)
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Mar 2003
Location: Hull, UK
Posts: 2,537 netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 1 Week 2 Days 18 h 17 m 47 sec
Reputation Power: 67
Send a message via ICQ to netytan Send a message via AIM to netytan Send a message via MSN to netytan Send a message via Yahoo to netytan
Like it Grim!

That is if you hadn't guessed by the fact that I've stuck this thread to the top of the forum [for the time being] . Anyway, one trivial thing I would add is an alternative way to get the command prompt/DOS prompt under Windows,

Quote:
Start > Run > Type 'command' or 'cmd'


This isn't really that important... just a personal preference really and very handy little thing to know in general . Very cool!

Mark.
__________________
programming language development: www.netytan.com Hula


Reply With Quote
  #4  
Old December 9th, 2004, 03:09 PM
jacktasia jacktasia is offline
Contributing User
Dev Shed Intermediate (1500 - 1999 posts)
 
Join Date: Feb 2004
Location: Lawrence, Kansas [KU]
Posts: 1,559 jacktasia User rank is Corporal (100 - 500 Reputation Level)jacktasia User rank is Corporal (100 - 500 Reputation Level)jacktasia User rank is Corporal (100 - 500 Reputation Level)jacktasia User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 2 Days 14 h 10 m 18 sec
Reputation Power: 13
Send a message via AIM to jacktasia
another thing to keep in mind is that you can get to Run Dialog very fast using: Window Button+R

because using the mouse sucks.
Comments on this post
Eeeman agrees: nice little tip for an amateur like myself

Reply With Quote
  #5  
Old December 15th, 2004, 03:01 PM
djjhouse djjhouse is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2004
Location: Colorado, USA
Posts: 68 djjhouse User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Day 15 h 7 m 19 sec
Reputation Power: 8
Another good py2exe resource

This has helped me a number of times

PY2exe wiki
http://starship.python.net/crew/theller/moin.cgi/Py2Exe

Reply With Quote
  #6  
Old December 16th, 2004, 04:31 AM
Grim Archon's Avatar
Grim Archon Grim Archon is offline
Mini me.
Dev Shed Novice (500 - 999 posts)
 
Join Date: Nov 2003
Location: Cambridge, UK
Posts: 783 Grim Archon User rank is Corporal (100 - 500 Reputation Level)Grim Archon User rank is Corporal (100 - 500 Reputation Level)Grim Archon User rank is Corporal (100 - 500 Reputation Level)Grim Archon User rank is Corporal (100 - 500 Reputation Level)  Folding Points: 1488 Folding Title: Novice Folder
Time spent in forums: 3 Days 2 h 15 m 57 sec
Reputation Power: 11
Send a message via MSN to Grim Archon
Quote:
Originally Posted by djjhouse
This has helped me a number of times

PY2exe wiki
http://starship.python.net/crew/theller/moin.cgi/Py2Exe


Yep - everything you need is already described on the official py2exe website and wiki. But - based on the number of forum posts it is clear that people don't get it

My aim was to illustrate few basics such as:
* Python code is stored as modules and they are text files
* Setup.py is separate from the module you want to compile
* Create a workspace directory
* Use a DOS box to run Python


These seem to be the things that first timers don't quite get and yet the tools they want to use assume these things are already understood.

grimey

Reply With Quote
  #7  
Old January 31st, 2005, 07:21 PM
wx_uab wx_uab is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2004
Location: Bimingham,AL
Posts: 68 wx_uab User rank is Private First Class (20 - 50 Reputation Level)wx_uab User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 14 h 58 m 22 sec
Reputation Power: 8
Using Py2exe with Python Imaging Library (PIL )

Using Py2exe with Python Imaging Library (PIL )

Creating standalone windows executables on widows using is py2exe is pretty straight forward . But you might sometime run into unexpected problems like
You might get the follwing errors while running the exe file created by the py2exe


1 . LookupError: no codec search functions registered: can't find encodingsolution : explicitly include the encodings package:

like this : python setup.py py2exe -p encodings

Un located modules *are* normal. A lot of modules have conditional
imports of other modules that they don't really *need*. This means
py2exe tries to include them in case they are needed. This sometimes
means you have more modules than you really need - and also reports of
modules that can't be found.

2 . Include the PIL switch on the py2exe line
The py2exe line needs to be:
python setup.py py2exe -p encodings –pPIL

It worked for me even without that switch use that in case u run into problems .

3 . File "Image.pyc", line 1571, in open
IOError: cannot identify image file

Solution : In order to make PIL and PY2EXE work together all libraries of PIL need to be imported explicitly such as:

import Image
import BmpImagePlugin # if you are using bitmaps
Import JpgImagePlugin # if you are dealing with jpg images

So forth ..
Note : These explicit imports may not be necessary if you are running the python script directly but are needed if you are running the exe file created by py2exe .
Comments on this post
pabloj agrees!

Reply With Quote
  #8  
Old April 13th, 2005, 03:54 PM
Max Dismukes Max Dismukes is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2005
Posts: 54 Max Dismukes User rank is Corporal (100 - 500 Reputation Level)Max Dismukes User rank is Corporal (100 - 500 Reputation Level)Max Dismukes User rank is Corporal (100 - 500 Reputation Level)Max Dismukes User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 6 h 23 m 42 sec
Reputation Power: 9
awesome man

Reply With Quote
  #9  
Old May 1st, 2005, 11:34 AM
shearn89 shearn89 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2005
Posts: 7 shearn89 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 15 m 16 sec
Reputation Power: 0
you legend! i've been trying to get py2exe to work all day!

Reply With Quote
  #10  
Old July 27th, 2005, 09:53 AM
mulciber mulciber is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2005
Location: OH
Posts: 12 mulciber User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 14 m 21 sec
Reputation Power: 0
This may be a dumb question, but is there a way to make an installer for the files generated by py2exe?

Reply With Quote
  #11  
Old July 27th, 2005, 04:31 PM
Grim Archon's Avatar
Grim Archon Grim Archon is offline
Mini me.
Dev Shed Novice (500 - 999 posts)
 
Join Date: Nov 2003
Location: Cambridge, UK
Posts: 783 Grim Archon User rank is Corporal (100 - 500 Reputation Level)Grim Archon User rank is Corporal (100 - 500 Reputation Level)Grim Archon User rank is Corporal (100 - 500 Reputation Level)Grim Archon User rank is Corporal (100 - 500 Reputation Level)  Folding Points: 1488 Folding Title: Novice Folder
Time spent in forums: 3 Days 2 h 15 m 57 sec
Reputation Power: 11
Send a message via MSN to Grim Archon
Quote:
Originally Posted by mulciber
This may be a dumb question, but is there a way to make an installer for the files generated by py2exe?


Not a dumb question at all

I use the excellent INNO Setup which seems to handle everything I need.

grim

Reply With Quote
  #12  
Old July 27th, 2005, 09:16 PM
mulciber mulciber is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2005
Location: OH
Posts: 12 mulciber User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 14 m 21 sec
Reputation Power: 0
Excellent. I tried it using the example setup.py that came with py2exe for use with INNO and it worked almost perfectly except for a dll that somehow didn't get linked. I have to investigate further for what may have happened, it was msvcr71.dll. Thanks for the tip and clean tut.

Reply With Quote
  #13  
Old September 1st, 2005, 12:51 AM
Dietrich's Avatar
Dietrich Dietrich is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2005
Posts: 350 Dietrich User rank is Sergeant (500 - 2000 Reputation Level)Dietrich User rank is Sergeant (500 - 2000 Reputation Level)Dietrich User rank is Sergeant (500 - 2000 Reputation Level)Dietrich User rank is Sergeant (500 - 2000 Reputation Level)Dietrich User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 2 Days 11 h 53 m 20 sec
Reputation Power: 26
Smile

I have modified Paul Hardwick's code when using Py2Exe with wxPython to avoid the codec LookupError when you run the exe file.
Code:
# run this code to create a windows exe file
# save in the working directory where your code file is
# and run the program from there
from distutils.core import setup
import py2exe
import sys

sys.argv.append("py2exe")

# usually needed for wxPython code to prevent the
# "LookupError: no codec search functions registered" when you run the exe
opt = {"py2exe": {"packages": ["encodings"]}}

# insert your own code filename here ...
setup(options = opt, windows = [{"script": 'myCodeFile.py'}])

Reply With Quote
  #14  
Old September 9th, 2005, 12:28 PM
djjhouse djjhouse is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2004
Location: Colorado, USA
Posts: 68 djjhouse User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Day 15 h 7 m 19 sec
Reputation Power: 8
FYI--new py2exe version released --0.6.2

The new version has a nifty option that can allow you to create a fast standalone executable. Other installer packages usually unzip the exe into a temp dir and run it from there. The py2exe implementation does not.

You can bundle all of the files into a "Library.zip" and have a small executable, or bundle all into one .exe .

To create one large exe,simply add the line
Code:
zipfile=None
to your setup.py.
Then from the command line, call
Code:
python setup.py py2exe --bundle 1


The bundle 2 option, also does a little less bundling.

Reply With Quote
  #15  
Old January 21st, 2006, 02:55 PM
Dietrich's Avatar
Dietrich Dietrich is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2005
Posts: 350 Dietrich User rank is Sergeant (500 - 2000 Reputation Level)Dietrich User rank is Sergeant (500 - 2000 Reputation Level)Dietrich User rank is Sergeant (500 - 2000 Reputation Level)Dietrich User rank is Sergeant (500 - 2000 Reputation Level)Dietrich User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 2 Days 11 h 53 m 20 sec
Reputation Power: 26
Smile

I found this little gem in
C:\Python24\Lib\site-packages\py2exe\samples\singlefile\gui\setup.py
on my computer after installing version 6.3 of Py2Exe. It creates a single executable file from wxPython code. I modified it slightly, added more user comments and called it wxPython2Exe.py .
Code:
# Py2Exe version 6.3 setup file for wxPython GUI programs.
# Creates a single exe file.
# It's easiest to add this wxPython2Exe.py file into the same
# folder with the source file and an optional iconfile like "icon.ico"
# (if you add your own icon file, remove the comment in front of icon_resources).
# Simply change the filename to whatever you called your source file.
# Optionally edit the version info and add the name of your icon file.
# Now run wxPython2Exe.py ...
# Two subfolders will be created called build and dist.
# The dist folder contains your .exe file, MSVCR71.dll and w9xpopen.exe
# Your .exe file contains your code, all neded modules and the Python interpreter.
# The MSVCR71.dll can be distributed, but is often already in the system32 folder.

from distutils.core import setup
import py2exe
import sys


# enter the filename of your wxPython code file to compile ...
filename = "wxCalc1.py"

# ... this creates the filename of your .exe file in the dist folder
if filename.endswith(".py"):
    distribution = filename[:-3]
elif filename.endswith(".pyw"):
    distribution = filename[:-4]


# if run without args, build executables in quiet mode
if len(sys.argv) == 1:
    sys.argv.append("py2exe")
    sys.argv.append("-q")

class Target:
    def __init__(self, **kw):
        self.__dict__.update(kw)
        # for the versioninfo resources, edit to your needs
        self.version = "0.6.3"
        self.company_name = "My Company"
        self.copyright = "no copyright"
        self.name = "WxPython Calculator"

################################################################
# The manifest will be inserted as resource into your .exe.  This
# gives the controls the Windows XP appearance (if run on XP ;-)
#
# Another option would be to store it in a file named
# test_wx.exe.manifest, and copy it with the data_files option into
# the dist-dir.
#
manifest_template = '''
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<assemblyIdentity
    version="5.0.0.0"
    processorArchitecture="x86"
    name="%(prog)s"
    type="win32"
/>
<description>%(prog)s Program</description>
<dependency>
    <dependentAssembly>
        <assemblyIdentity
            type="win32"
            name="Microsoft.Windows.Common-Controls"
            version="6.0.0.0"
            processorArchitecture="X86"
            publicKeyToken="6595b64144ccf1df"
            language="*"
        />
    </dependentAssembly>
</dependency>
</assembly>
'''

RT_MANIFEST = 24

# description is the versioninfo resource
# script is the wxPython code file
# manifest_template is the above XML code
# distribution will be the exe filename
# icon_resource is optional, remove any comment and give it an iconfile you have
#   otherwise a default icon is used
# dest_base will be the exe filename
test_wx = Target(
    description = "A GUI app",
    script = filename,
    other_resources = [(RT_MANIFEST, 1, manifest_template % dict(prog=distribution))],
    #icon_resources = [(1, "icon.ico")],
    dest_base = distribution)

################################################################

setup(
    options = {"py2exe": {"compressed": 1,
                          "optimize": 2,
                          "ascii": 1,
                          "bundle_files": 1}},
    zipfile = None,
    windows = [test_wx],
    )
Comments on this post
netytan agrees: Nice; not a Py2exe fan but its cool

Last edited by Dietrich : January 21st, 2006 at 02:59 PM.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPython Programming > PY2EXE step-by-step guide


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.

© 2003-2012 by Developer Shed. All rights reserved. DS Cluster 10 - Follow our Sitemap