[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] PY2EXE and Modules



 
Hi Luke
 
    I do not know either. All I know is that my main .py has several imports which are my other modules for specific tasks. The error comes at the very first import statement, line 12. Could it be because I use the from import statement?
 
    I can show you that file below. The batch files is my way of making a universal for all programs I make and may just do away with it since the work for making the module list is the same about of time to enter it into the setup.py file. Who knows, I just want to learn the py2exe so I can get it working.
 
    I have about 9 modules to import and apparently none of them are coming in with the py2exe. For when running the .exe I get the error. As log as I ma not importing any modules I get no errors in a simple test program.
 
        Bruce
 

I think you're making it more complicated than it needs to be.
I just took the example from the pygame website, and I took out all the crap that failed (presumably because it was for an older version of Pygame).
Then I ran it, and out popped a Build directory with an EXE inside.
Then I copied my data directories over to the Build folder, zipped it up, and sent it to people, and it worked fine.
I'll attach the script.

I don't really see why you're making such a complicated batch file for this.
You could put all of this scripting stuff inside the setup.py itself, and just use it that way.

This is confusing and unnecessarily complicated.
It's not necessary to import modules yourself.
Py2EXE will go through your code and determine all dependencies, and build a library.zip for you.

The only issue that could arise is if you're generating import strings dynamically at runtime and eval()ing them or something, but you probably shouldn't be doing that anyway.
-Luke
Main file:

#LAST MODIFIED DECEMBER 16, 2007
#ADDED GAME LEVEL TO THE GAME AND MISSION VARIABLE!
#MODIFIED DECEMBER 15, 2007
#ADDED WEAPON IMAGE FOR WHEN DEPLETED, YELLOW ALERT FOR ENTERPRISE IN GRID!
#MODIFIED DECEMBER 9, 2007
#ADDED THE OBJECTS TO THE GALAXY GRID, GG, AND TOOK THEM OFF THE STAR TREK PARM LIST!
#MODIFIED DECEMBER 2, 2007
#ADDED PLAY SOUND AND TIME DELAY!
#ADDED, MOVED, ALL INPUTS TO F_INPUT4TREK!
#SET UP ALL GALAXY VALUES! INIT TREK GAME!
from F_Init4Trek10 import Galaxy, Init_Galaxy, Help4Main
from random import randint, uniform
from F_Inputs4Trek10 import Star_Trek
from F_Sound import PlaySound, Time2Wait
#GALAXY SIZE!
ROW_MAX = 8
COLUMN_MAX = 8
#SYMBOLS AND IMAGES!
ESI="<[E]>"
KSI="<K>"
STI="*(O)*"
SBI=">)B(<"
WE0 = "WENE0"
 
#SET MAX VALUES FOR SHIPS, BASES, STARS, ROWS, COLUMNS, KLINGONS, STAR DATE OF GALAXY!
GG = Galaxy( randint(9,30), randint(3,9), randint(60, 100), ROW_MAX, COLUMN_MAX, 0, uniform(30, 70), 0.0,0.0,0,0,0.0,0.0,0.0,0,0,0, "COM","", ESI,KSI,STI,SBI,WE0, [],[],[])
GG.KL = GG.SSM-1 #KLINGONS LEFT!
GG.SDT = uniform(3000, 5000) #STARTING STARDATE!
GG.SDS = GG.SDT #START STAR DATE!
GG.SD += GG.SDT #ENDING STAR DATE!
GG.MISSION = "Star Fleet Command Says "
GG.MISSION += "Your Mission is: \n You are to capture and destroy " +str( GG.KL) +" Klingons in " +str(int( GG.SD-GG.SDT)) +" Star Dates! \n"
GG.MISSION += "The galaxy has " +str(GG.STM) +" Stars, and " +str(GG.BSM) +" Star Bases For Refueling!\n"
GG.MISSION += "It is now Star Date " +str(int( GG.SDT)) +"\n So good luck!"
 
GAL = {} # DICTIONARY OF GALAXY VALUES AND GRIDS!
Init_Galaxy(GAL, GG)
print "Location At Start Of The Game:"
print "%s Quadrant (%d,%d) Sector (%d,%d)" % (GG.SS[0].N, GG.SS[0].Qy, GG.SS[0].Qx, GG.SS[0].Sy, GG.SS[0].Sx)
 
print GG.MISSION
PlaySound("Trek_Theme.wav", 0, 20)
print "Please Press Enter To Start The Game!"
i=raw_input("___> ")
 
#PLAY THE GAME NOW!
Star_Trek(GAL, GG)
 
if GG.KL>0:
    PlaySound ("Fail.Wav", 0, -1)
Time2Wait(4) #SECONDS BEFORE PROGRAM SHUTS IT OFF!