简体   繁体   中英

Pyinstaller EXE Crashing Upon Start

So I'm not sure if this is the correct place to put this, but I'm attempting to transfer my Pygame file into something that would be more universal. The first platform is Windows. It was working for me perfectly until I added in some code related to the Glyph library ( http://www.pygame.org/project-Glyph-1002-.html )

Now it crashes upon start, and I'm really not sure why. Can anyone help me with this? I've never done a traceback or anything, Here's the zip to my game if it helps, I'm trying to do this with the --onefile command.

https://www.dropbox.com/sh/5x143gx95f6sy8j/AADsnPZFwdlrVpc1b8G8QcRja?dl=0

The things I've tried are such: Adding --hiddenfile=Glyph, checking the warning file that's created, and debugging myself by changing lines in my game, googling this till my fingers bled

The things I couldn't try because I couldn't find enough info: Tracebacks, Console as to why it wasn't working, Creating a log file that would tell me whats going wrong because i couldn't figure it out.

The only thing that has severely changed was my Windows 10 updated, which could have something to do with why it's not working I'm sure.

Thanks! - Zach

I have tested your game on Linux and had great fun when run in Python interpreter. I have had an error when using PyInstaller. As you did not post your error I don't know if it is the same. (-1 for you!) If your error is

Fatal Python error: (pygame parachute) Segmentation Fault

I have a hint for you where to look. The problem is lies in the glyph.py and editor.py in the font initialization:

FONT = Font(None,8)

This tires to initialize the default font. But it is not available. If you have been googling you might have found this or this

So what I did is to modify the glymph.py and editor.py (made a local copy and modified this) and have changed the font loading to

FONT = Font('silkscreen.ttf', 8)

The silkscreen.ttf or any other font must be available in your working dir. The error went away.

You might wand to adapt all your paths according to this hint .

import sys
import os
...
if getattr(sys, 'frozen', False):
    # we are running in a bundle
    basedir = sys._MEIPASS
else:
    # we are running in a normal Python environment
    basedir = '.'

and use

basedir + os.sep + 'your file name'

in all sources.

If you want to make your game work on Linux, please change the file Sounds/GBMusic.mp3 to ogg format. Unfortunately I did not manage to make the background music work (100% CPU). So I have commented out the line:

pygame.mixer.music.play(-1)

I hope I could help with your problem and could give some hints for further development.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM