If I use relative path in main.py pyinstaller --onefile dont work
If I use absolute path in main.py pyinstaller --onefile work
my commands
pyi-makespec --onefile --windowed main.py
pyinstaller main.spec
my code
import pygamefrom pygame.time
import Clockfrom pygame.locals import *
import sysSCREEN_WIDTH = 400
SCREEN_HEIGHT = 600
pygame.init()FPS = 30
clock = Clock()
SCREEN_SURFACE = pygame.display.set_mode((SCREEN_WIDTH, SCREEN_HEIGHT))
this works
image = pygame.image.load("/absolute/path/image.png").convert_alpha()
while True:
for event in pygame.event.get():
if event.type == QUIT:
pygame.quit()
sys.exit()
pygame.display.update()
clock.tick(FPS)
this does not works
image = pygame.image.load("relative/path/image.png").convert_alpha()
while True:
for event in pygame.event.get():
if event.type == QUIT:
pygame.quit()
sys.exit()
pygame.display.update()
clock.tick(FPS)
my spec file
-- mode: python ; coding: utf-8 --
block_cipher = None
a = Analysis(['main.py'],
pathex=[],
binaries=[],
datas=[("relative/path/image.png", "relative/path"),],
hiddenimports=[],
hookspath=[],
hooksconfig={},
runtime_hooks=[],
excludes=[],
win_no_prefer_redirects=False,
win_private_assemblies=False,
cipher=block_cipher,
noarchive=False)
pyz = PYZ(a.pure, a.zipped_data,
cipher=block_cipher)
exe = EXE(pyz,
a.scripts,
a.binaries,
a.zipfiles,
a.datas,
[],
name='main',
debug=False,
bootloader_ignore_signals=False,
strip=False,
upx=True,
upx_exclude=[],
runtime_tmpdir=None,
console=False,
disable_windowed_traceback=False,
target_arch=None,
codesign_identity=None,
entitlements_file=None )