安装 pyinstaller 插件打包exe ------遇到的错误解决方法

1.

安装pyinstaller时遇到的错误:解决方法见这里

2.

打包完成后运行时遇到的错误
解决见这里https://www.liangzl.com/get-article-detail-167200.html

提示failed to execute script xxxs 的错误:
解决见这里

之后又遇到了恶心的问题:
运行exe程序先是黑屏,然后就卡了,最后自动退出

E:\飞机大战2\dist\9.1>9.1.exe
pygame 1.9.6
Hello from the pygame community. https://www.pygame.org/contribute.html
libpng warning: iCCP: known incorrect sRGB profile
libpng warning: iCCP: cHRM chunk does not match sRGB

在这里插入图片描述
找了好久终于找出错误了,吐了,原来是字体的问题,把字体None改了就行了
参考了这篇文章:https://blog.csdn.net/sinat_37185987/article/details/78634190

改之前:

# 分数类
class Score():
    def __init__(self):
        self.score = 0
        self.score_font = pygame.font.Font(None, 60)  # 字体,字号。注意字体一定不要用None,否者打包后会运行不了

改后:

# 分数类
class Score():
    def __init__(self):
        self.score = 0
        self.score_font = pygame.font.Font("Font/arial.ttf", 60)  # 字体,字号。注意字体一定不要用None,否者打包后会运行不了

打开运行:
在这里插入图片描述
在这里插入图片描述
问题完美解决。

自此,从安装pyinstaller到运行 打包后的游戏 中所遇到的问题全部解决。


版权声明:本文为weixin_42118981原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。