473,695 Members | 2,647 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

PY2EXE - Strange Things a-Happenin

Hello,

So I've been playing with Python and Pygame for a while and I decided
I wanted to make a real executable so I could send that stuff over to
my friends to show off my <sarcasm>maad skillz</sarcasm>.

Everything was going great I went and got all the newest software
(including Distutils and PY2EXE) and read the docs on making a setup
py.

Following is my setup.py: Sorry if It's a little long:
---------------------------------------------------------
#make standalone, needs at least pygame-1.5.3 and py2exe-0.3.1

from distutils.core import setup
import sys, os, pygame, shutil
import py2exe

#setup the project variables here.
#i can't claim these will cover all the cases
#you need, but they seem to work for all my
#projects, just change as neeeded.

script = "cards.py" #name of starting .PY
icon_file = "" #ICO file for the .EXE (not working well)
optimize = 2 #0, 1, or 2; like -O and -OO
dos_console = 0 #set to 0 for no dos shell when run
extra_data = ['readme.txt'] #extra files/dirs copied to game
extra_modules = ['pygame.locals'] #extra python modules not auto
found

#use the default pygame icon, if none given
if not icon_file:
path = os.path.split(p ygame.__file__)[0]
icon_file = '"' + os.path.join(pa th, 'pygame.ico') + '"'
#unfortunately, this cool icon stuff doesn't work in current py2exe :(
#icon_file = ''
#create the proper commandline args
args = ['py2exe', '--force', '-O'+`optimize`]
args.append(dos _console and '--console' or '--windows')
if icon_file:
args.append('--icon')
args.append(ico n_file)
args.append('--force-imports')
args.append(',' .join(extra_mod ules))
#args.append(', '.join(pygame_m odules + extra_modules))
sys.argv[1:] = args + sys.argv[1:]

project_name = os.path.splitex t(os.path.split (script)[1])[0]
#this will create the executable and all dependencies
setup(name=proj ect_name, scripts=[script])

#also need to hand copy the extra files here
def installfile(nam e):
dst = os.path.join('d ist', project_name)
print 'copying', name, '->', dst
if os.path.isdir(n ame):
dst = os.path.join(ds t, name)
if os.path.isdir(d st):
shutil.rmtree(d st)
shutil.copytree (name, dst)
elif os.path.isfile( name):
shutil.copy(nam e, dst)
else:
print 'Warning, %s not found' % name

pygamedir = os.path.split(p ygame.base.__fi le__)[0]
installfile(os. path.join(pygam edir, pygame.font.get _default_font() ))
installfile(os. path.join(pygam edir, 'pygame_icon.bm p'))
for data in extra_data:
installfile(dat a)
---------------------------------------------------------

I got this from some 'here's how to make a setupfile site'. I started
using this one after the one I made caused me errors... Unfortunately
this one does the same.

I'm using IDLE (but I did also try this in the cmd prompt) so I got
ahead and F5 this setup file and it goes ahead and haks away for a few
seconds (on my pos pII 450). Shortly I recieve this block of
statements and errors:

Traceback (most recent call last):
File "C:\Documen ts and Settings\Admini strator\My
Documents\Proje cts\Pygame Projects\Cards\ pygame2exe.py", line 48, in
-toplevel-
setup(name=proj ect_name, scripts=[script])
File "C:\DOCUME~1\AD MINI~1\MYDOCU~1 \Projects\Pytho n\distutils\cor e.py",
line 101, in setup
_setup_distribu tion = dist = klass(attrs)
File "C:\DOCUME~1\AD MINI~1\MYDOCU~1 \Projects\Pytho n\Lib\site-packages\py2exe \__init__.py",
line 75, in __init__
distutils.dist. Distribution.__ init__(self, attrs)
File "C:\DOCUME~1\AD MINI~1\MYDOCU~1 \Projects\Pytho n\distutils\dis t.py",
line 130, in __init__
setattr(self, method_name, getattr(self.me tadata, method_name))
AttributeError: DistributionMet adata instance has no attribute
'get___doc__'
I looked up the last line in google and found a few posts noting the
same difficulties and I was led to believe that it was some kind of
'mistake'...

....

needless to say I was confused. I decided I could write a pretty good
cry for help (including lots of info etc) so I am now asking you for
help.

All I want to do is make my stupid little program an executable! :)
HELP!!!

Extra Info:
Python Version:2.3.3
Pygame Version:1.6
Distutils Version:1.0.2
PY2EXE Version:0.5.0
OS: Windows 2000 Pro

Thanks in advance!!!
Jul 18 '05 #1
1 2587

"Funduk" <fu*****@rogers .com> wrote in message
news:74******** *************** ***@posting.goo gle.com...
Hello,

So I've been playing with Python and Pygame for a while and I decided
I wanted to make a real executable so I could send that stuff over to
my friends to show off my <sarcasm>maad skillz</sarcasm>.

Everything was going great I went and got all the newest software
(including Distutils and PY2EXE) and read the docs on making a setup
py.

Following is my setup.py: Sorry if It's a little long:
---------------------------------------------------------
#make standalone, needs at least pygame-1.5.3 and py2exe-0.3.1

from distutils.core import setup
import sys, os, pygame, shutil
import py2exe

#setup the project variables here.
#i can't claim these will cover all the cases
#you need, but they seem to work for all my
#projects, just change as neeeded.

script = "cards.py" #name of starting .PY
icon_file = "" #ICO file for the .EXE (not working well)
optimize = 2 #0, 1, or 2; like -O and -OO
dos_console = 0 #set to 0 for no dos shell when run
extra_data = ['readme.txt'] #extra files/dirs copied to game
extra_modules = ['pygame.locals'] #extra python modules not auto
found

#use the default pygame icon, if none given
if not icon_file:
path = os.path.split(p ygame.__file__)[0]
icon_file = '"' + os.path.join(pa th, 'pygame.ico') + '"'
#unfortunately, this cool icon stuff doesn't work in current py2exe :(
#icon_file = ''
#create the proper commandline args
args = ['py2exe', '--force', '-O'+`optimize`]
args.append(dos _console and '--console' or '--windows')
if icon_file:
args.append('--icon')
args.append(ico n_file)
args.append('--force-imports')
args.append(',' .join(extra_mod ules))
#args.append(', '.join(pygame_m odules + extra_modules))
sys.argv[1:] = args + sys.argv[1:]

project_name = os.path.splitex t(os.path.split (script)[1])[0]
#this will create the executable and all dependencies
setup(name=proj ect_name, scripts=[script])

#also need to hand copy the extra files here
def installfile(nam e):
dst = os.path.join('d ist', project_name)
print 'copying', name, '->', dst
if os.path.isdir(n ame):
dst = os.path.join(ds t, name)
if os.path.isdir(d st):
shutil.rmtree(d st)
shutil.copytree (name, dst)
elif os.path.isfile( name):
shutil.copy(nam e, dst)
else:
print 'Warning, %s not found' % name

pygamedir = os.path.split(p ygame.base.__fi le__)[0]
installfile(os. path.join(pygam edir, pygame.font.get _default_font() ))
installfile(os. path.join(pygam edir, 'pygame_icon.bm p'))
for data in extra_data:
installfile(dat a)
---------------------------------------------------------

I got this from some 'here's how to make a setupfile site'. I started
using this one after the one I made caused me errors... Unfortunately
this one does the same.

I'm using IDLE (but I did also try this in the cmd prompt) so I got
ahead and F5 this setup file and it goes ahead and haks away for a few
seconds (on my pos pII 450). Shortly I recieve this block of
statements and errors:

Traceback (most recent call last):
File "C:\Documen ts and Settings\Admini strator\My
Documents\Proje cts\Pygame Projects\Cards\ pygame2exe.py", line 48, in
-toplevel-
setup(name=proj ect_name, scripts=[script])
File "C:\DOCUME~1\AD MINI~1\MYDOCU~1 \Projects\Pytho n\distutils\cor e.py",
line 101, in setup
_setup_distribu tion = dist = klass(attrs)
File "C:\DOCUME~1\AD MINI~1\MYDOCU~1 \Projects\Pytho n\Lib\site-packages\py2exe \__in
it__.py", line 75, in __init__
distutils.dist. Distribution.__ init__(self, attrs)
File "C:\DOCUME~1\AD MINI~1\MYDOCU~1 \Projects\Pytho n\distutils\dis t.py",
line 130, in __init__
setattr(self, method_name, getattr(self.me tadata, method_name))
AttributeError: DistributionMet adata instance has no attribute
'get___doc__'
I looked up the last line in google and found a few posts noting the
same difficulties and I was led to believe that it was some kind of
'mistake'...

...

needless to say I was confused. I decided I could write a pretty good
cry for help (including lots of info etc) so I am now asking you for
help.

All I want to do is make my stupid little program an executable! :)
HELP!!!

Extra Info:
Python Version:2.3.3
Pygame Version:1.6
Distutils Version:1.0.2
PY2EXE Version:0.5.0
OS: Windows 2000 Pro

Thanks in advance!!!


You say you used the command prompt, but in what way?? Did you type in
"python setup.py py2exe"?? Adding the "py2exe" is what tells python to use
py2exe along with importing it into your setup script. You can't run your
setup script using IDLE or the interactive interpreter. It has to be run
from the command line.
Jul 18 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
5500
by: Simon Dahlbacka | last post by:
I'm "exefying" an application that uses wxpython, some com to control excel and word and want to distribute this application. after creating the executable with py2exe, it still works fine (at least on my development machine), however, if I create an installer package with innosetup, install it and try to run it, I get a busy cursor for a split second and then.. nothing. no errors no traceback no nothing.. viewing dependencies does not...
1
1799
by: Thomas Heller | last post by:
This is a bugfix release for py2exe 0.6.1. py2exe 0.6.2 released ===================== py2exe is a Python distutils extension which converts python scripts into executable windows programs, able to run without requiring a python installation. Console and Windows (GUI) applications, windows NT services, exe and dll COM servers are supported.
2
1635
by: Jimmy Retzlaff | last post by:
I am taking over the maintenance and support of py2exe from Thomas Heller. As he announced a few weeks ago he is looking to focus on other things. py2exe has been very useful to me over the years and I look forward to keeping it every bit as useful in the future. I plan to make the transition as smooth as possible for users of py2exe. I don't plan to make changes to the license other than adding my name to the list of people not to sue....
0
1399
by: Jimmy Retzlaff | last post by:
py2exe 0.6.3 released ===================== py2exe is a Python distutils extension which converts Python scripts into executable Windows programs, able to run without requiring a Python installation. Console and Windows (GUI) applications, Windows NT services, exe and dll COM servers are supported. Changes in 0.6.3:
0
1529
by: Jimmy Retzlaff | last post by:
py2exe 0.6.4 released ===================== py2exe is a Python distutils extension which converts Python scripts into executable Windows programs, able to run without requiring a Python installation. Console and Windows (GUI) applications, Windows NT services, exe and dll COM servers are supported. Changes in 0.6.4:
0
1513
by: Jimmy Retzlaff | last post by:
py2exe 0.6.5 released ===================== py2exe is a Python distutils extension which converts Python scripts into executable Windows programs, able to run without requiring a Python installation. Console and Windows (GUI) applications, Windows NT services, exe and dll COM servers are supported. Changes in 0.6.5:
0
1723
by: Jimmy Retzlaff | last post by:
py2exe 0.6.6 released ===================== py2exe is a Python distutils extension which converts Python scripts into executable Windows programs, able to run without requiring a Python installation. Console and Windows (GUI) applications, Windows NT services, exe and dll COM servers are supported. Changes in 0.6.6:
1
2979
by: Jimmy Retzlaff | last post by:
py2exe 0.6.8 released ===================== py2exe is a Python distutils extension which converts Python scripts into executable Windows programs, able to run without requiring a Python installation. Console and Windows (GUI) applications, Windows NT services, exe and dll COM servers are supported. Changes in 0.6.8:
0
1522
by: Larry Bates | last post by:
Jimmy Retzlaff wrote: Everyone, Thanks for all your hard work on py2exe, it is greatly appreciated. -Larry Bates
0
3115
by: Jimmy Retzlaff | last post by:
py2exe 0.6.9 released ===================== py2exe is a Python distutils extension which converts Python scripts into executable Windows programs, able to run without requiring a Python installation. Console and Windows (GUI) applications, Windows NT services, exe and dll COM servers are supported. Changes in 0.6.9:
0
8617
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, weíll explore What is ONU, What Is Router, ONU & Routerís main usage, and What is the difference between ONU and Router. Letís take a closer look ! Part I. Meaning of...
0
9112
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8822
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8815
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6483
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Duprť who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5827
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4332
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4570
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2994
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.