|
发表于 2020-8-28 19:45:20
|
显示全部楼层
本帖最后由 疾风怪盗 于 2020-8-28 19:46 编辑
要查看错误提示,而不是窗口一闪而过,可以在地址栏输入cmd,然后运行你的exe文件,就会看到错误提示NotImplementedError: Can’t perform this operation for unregistered loader type
然后度娘一下,https://blog.csdn.net/u010098760/article/details/102966717,发现是字体问题,按照提示更改三处字体
- rp(relative_path):
- """ Get absolute path to resource, works for dev and for PyInstaller """
- try:
- # PyInstaller creates a temp folder and stores path in _MEIPASS
- base_path = sys._MEIPASS
- except Exception:
- base_path = os.path.abspath(".")
- return os.path.join(base_path, relative_path)
复制代码- BASICFONT = pygame.font.Font(rp('C:\Windows\Fonts\simsun.ttc'), 18)
- titleFont = pygame.font.Font(rp('C:\Windows\Fonts\simsun.ttc'), 100)
- gameOverFont = pygame.font.Font(rp('freesansbold.ttf'), 100)
复制代码
上面三个字体分别在你程序的三个地方,在添加那个rp代码后修改一下,要注意第三个,那个字体是不在系统内的,需要下载了放在py文件一起运行,然后再打包就能运行了 |
|