Question

I'd wish to compile my program wrote in Python 3.2 with Pygame 1.9.5. But I'm a beginner with cx_Freeze and I've no idea how to manage with the complex structure... I mean :

My folder is like that :

gamefolder:
lib:
    Menu.py (lauch the program)
    level.py
    othermodules.py
    ...
data:
    Level1.png
    otherspictures.png

So I tried to compile but I always get an error when I lauch Main.exe, indeed I think pygame is not load and also the path are not really clear.

I hope there's a solution, and that with such a structure it will not be impossible because I'd rather not rewrote each path in the scripts ...

Further informations :

the setup.py script is in lib folder and looks like that:

from cx_Freeze import setup, Executable
setup(
    name = "Resets",
    version = "1.0",
    description = "Jeu de plateforme - Projet ISN 2014",
    executables = [Executable("Menu.py")]
)

And i get this error when I launch the Menu.exe :

Traceback (most recent call last):
  File "C:\Python32\lib\site-packages\pygame\__init__.py", line 117, in <module>

    try: import pygame.display
  File "ExtensionLoader_pygame_display.py", line 22, in <module>
  File "ExtensionLoader_pygame_display.py", line 14, in __bootstrap__
  File "ExtensionLoader_pygame_surface.py", line 22, in <module>
  File "ExtensionLoader_pygame_surface.py", line 14, in __bootstrap__
ImportError: No module named _view

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Python32\lib\site-packages\cx_Freeze\initscripts\Console3.py", line 2
7, in <module>
    exec(code, m.__dict__)
  File "Menu.py", line 8, in <module>
  File "C:\Python32\lib\site-packages\pygame\__init__.py", line 118, in <module>

    except (ImportError,IOError):display=MissingModule("display", geterror(), 1)

  File "C:\Python32\lib\site-packages\pygame\__init__.py", line 61, in __init__
    self.warn()
  File "C:\Python32\lib\site-packages\pygame\__init__.py", line 85, in warn
    warnings.warn(message, RuntimeWarning, level)
  File "C:\Python\32-bit\3.2\lib\warnings.py", line 18, in showwarning
  File "C:\Python\32-bit\3.2\lib\warnings.py", line 25, in formatwarning
  File "C:\Python\32-bit\3.2\lib\linecache.py", line 15, in getline
  File "C:\Python\32-bit\3.2\lib\linecache.py", line 41, in getlines
  File "C:\Python\32-bit\3.2\lib\linecache.py", line 127, in updatecache
  File "C:\Python\32-bit\3.2\lib\codecs.py", line 300, in decode
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x90 in position 2: invalid
start byte

I already try with import pygame._view and import re but it doesn't work too...

Était-ce utile?

La solution

Finally I succeeded, it was very simple ! I added import pygame._view in each script. And I copied the data folder into the folder (after being compiled).

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top