Frage

The following error happens if i try to compile my python (using python 3.2) file:

Traceback(most recent call last):
File
"c:\python32\lib\site-packages\cx_Freeze\initscripts\Console3.py", line
27, in <module>
  exec(code, m.__dict__)
 File "Abertura.py", line 208, in <module>
 File "Abertura.py", line 154, in main
 File "Abertura.py", line 9, in __init__
pygame.error: Couldn't open
C:\Python32\build\exe.win32-3.2\library.zip\Imagens\menu1.png

I already included pygame._view and tried to copy the 'Imagens' directory to the library.zip file, but it doesn't work. I'm using images, musics and videos that come's from other directories by including in my code:

def file_path(filename, directory):
    return os.path.join(
        os.path.dirname(os.path.abspath(__file__)),
        directory,
        filename
    )

And this is my setup.py file:

from cx_Freeze import setup, Executable

exe=Executable(
     script="Abertura.py",
     base="Win32Gui",
     )
includefiles=[('C:\Python32\Imagens', 'Imagens'), 
              ('C:\Python32\Musicas','Musicas'),
              ('C:\Python32\Videos','Videos')
              ]
includes=[]
excludes=[]
packages=[]
setup(
     version = "1.0",
     description = "RPG",
     author = "Pedro Forli e Ivan Veronezzi",
     name = "Batalha Inapropriada",
     options = {'build_exe':   {'excludes':excludes,'packages':packages,'include_files':includefiles}},
     executables = [exe]
     )

How do i fix it? (sorry about my possibles english mistakes)

War es hilfreich?

Lösung

Anything accessed from within a compressed archive (such as zips, rars, tar.gzs, etc...) need to be decompressed first before you access them.

That being said, you should not have your recourse files in a zip because decompressing it every time to want to access something is slow, and difficult. Your resource files should be in a normal directory, not an archive.

The reason why you're getting this error is because it's looking for a folder named library.zip and it's not finding one because library.zip is not a folder, it's a file.

How I would suggest to combat this error is to extract everything into a folder named library and to change in your code anywhere that library.zip exists to library.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top