我一直试图从我的.py游戏制作一个.exe,这真的令人沮丧.
我使用的是Python 3.5.2,Pygame 1.9.2和Pyinstaller 3.2.
这个游戏完全像.py一样运行,但是在我输入之后pyinstaller --debug game.py,.exe被构建并运行它,我得到以下内容:
这些是game.py中可能与错误相关的代码行:
from os import path
img_dir = path.join(path.dirname(__file__), 'sprites')
title_screen = pygame.image.load(path.join(img_dir, 'title_screen.png'))
Run Code Online (Sandbox Code Playgroud)
我认为它必须与pyinstaler无法获取我的sprites文件夹有关,因为当我尝试运行时pyinstaller --icon=/sprites/icon.ico game.py,我得到这个:
但是,如果我使用pyinstaller --icon=icon.ico game.py它加载图标就好了.
这是我的spec文件:
# -*- mode: python -*-
block_cipher = None
added_files = [
( '/sprites', 'sprites' ),
( '/music', 'music' ),
( 'Heavitas.ttf', '.'),
( 'Roboto-Light.ttf', '.'),
( 'high scores.csv', '.')
]
a = Analysis(['spec_file.py'],
pathex=['C:\\Users\\rodri\\Documents\\Code\\The Color That Fell From The Sky'],
binaries=None,
datas=added_files,
hiddenimports=[],
hookspath=[], …Run Code Online (Sandbox Code Playgroud) 我在Pygame 1.9.2中使用Python 3.5.2,一切正常.然后我决定尝试使用全新安装最近发布的Python 3.6.0,但是当我尝试使用以下方法重新安装Pygame时:
pip install pygame
Run Code Online (Sandbox Code Playgroud)
它返回以下内容:
Collecting pygame
Downloading pygame-1.9.2.tar.gz (3.0MB)
100% |????????????????????????????????| 3.0MB 292kB/s
Complete output from command python setup.py egg_info:
WARNING, No "Setup" File Exists, Running "config.py"
Using WINDOWS configuration...
Path for SDL not found.
Too bad that is a requirement! Hand-fix the "Setup"
Path for FONT not found.
Path for IMAGE not found.
Path for MIXER not found.
Path for PNG not found.
Path for JPEG not found.
Path for PORTMIDI not found.
Path for …Run Code Online (Sandbox Code Playgroud)