0
\$\begingroup\$

My directory for my Pygame program looks something like this:

[Parent directory]
    lib
        engine
            Various .py files
        graphics
            spritesheet.py
            spritesheet.png
    skeleton.py (starter script)
    font.ttf
    spritesheet.png
    pygame2exe.py (Pygame2Exe script)

When I run pygame2exe.py (found here, everything seems fine: the dist directory is created with an executable file and all the necessary dlls. However, when I try to run the program, it says I cannot find the file "lib\graphics\spritesheet.png"

I've tried to manually insert the image file by using 7zip to "open" the .exe; however 7zip doesn't support it. That seemed to be the best solution, but now I am stumped. Does anyone have an answer?

\$\endgroup\$

1 Answer 1

1
\$\begingroup\$

In pygame2exe.py, there's a section which reads:

#Extra files to be included in the dist directory  
                  #directory #files 
extra_files = [ #("",        ["README.txt"]),
              ]

You should add your content (spritesheet.png, font.ttf) into this array and run pygame2exe again.

\$\endgroup\$
2
  • \$\begingroup\$ I tried something like this: extra_files = [("lib/graphics", ["spritesheet.png"])] however, the picture itself doesn't appear in the executable itself -- it appears in the dist/lib/graphics directory... \$\endgroup\$
    – Y-M
    Mar 25, 2014 at 21:28
  • \$\begingroup\$ @Y-M that appears to be a limitation of pygame2exe itself - try changing your game code to look for all assets in a dist directory \$\endgroup\$ Mar 25, 2014 at 23:16

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .