pygame - Where to put images folder in python exe? -


i have converted python game designed exe. running exe causes flash , close, meaning error has occured. running command prompt causes error well, documents it:

cannot load image: playfield.png couldn't open images\playfield.png 

this telling me load_image block failing. have encountered before when did not have images directory.

i attempted move images folder dist directory. error shows up:

traceback (most recent call last):     file "table_wars.py", line 728, in <module>     file "table_wars.py", line 51, in main     file "table_wars.py", line 236, in __init__     file "pygame\__init__.pyc", line 70, in __getattr__ notimplementederror: font module not available (importerror: dll load failed: specified module not found.) 

this first time py2exe, i'm not sure happening. raw python file itself, table_wars.py, runs expected.

if helps, location entire table_wars folder inside folder called games, located on desktop (c:\users\oventoaster\desktop\games\table_wars). running windows 7 32 bit os.

on request, here output.txt have generated:

folder path listing volume os volume serial number 7659-4c9c c:\users\oventoaster\desktop\games\table_wars build    bdist.win32        winexe            bundle-2.7            collect-2.7               ctypes               distutils               email                  mime               encodings               logging               multiprocessing                  dummy               pygame                  threads               unittest               xml                   parsers            temp dist images 

here setup.py used convert file:

from distutils.core import setup import py2exe  setup(console=['table_wars.py']) 

edit: have attempted use full py2exe example. create exe, gives same cannot load image error. attempting put images folder in same folder exe creates runtime error: application requested runtime terminate in unusual way.

the shortened form of code slace diamond suggested prevents py2exe finding table_wars.py:

from cmd:

running py2exe *** searching required modules *** error: table_wars.py: no such file or directory. 

setup , table_wars in same directory. if help, input full path python.exe , setup.py.

edit: seem getting closer. put images directory within self.extra_datas, , getting this:

fatal python error: (segmentation fault) this application has requested runtime terminate in unusual way. please contact application's suppourt team more information

when build distributable package py2exe (and py2app matter), part of package environment point local resource location files. in plain unpackaged version, referring relative "images/" location. packaged version, need configure setup.py include resources in own location.

refer doc specific info how set data_files option of package: http://www.py2exe.org/index.cgi/data_files

that page has multiple examples show both simple paths, , helper function finding data , building data_files list you.

here example of simple snippet:

from distutils.core import setup import py2exe  mydata_files = [('images', ['c:/path/to/image/image.png'])]  setup(     console=['trypyglet.py.py']     data_files = mydata_files     options={                 "py2exe":{                         "unbuffered": true,                         "optimize": 2,                         "excludes": ["email"]                 }         } ) 

this closely matches trying achieve. saying "image.png" source file should placed "images" directory @ root of resources location inside package. resource root current directory python scripts, can continue refer relative sub directory.


Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -