嗨,我是 python 和 pygame 的新手,但我使用的是 Atom,但我无法解决这个问题。当我在 IDLE 中打开我的脚本时,它可以工作,但我不能让它在 Atom(特别是终端加)和终端上工作。我的错误信息是
Traceback (most recent call last):
File "cargame.py", line 32, in <module>
carImg = pygame.image.load('racecar.png')
pygame.error: Failed loading libpng.dylib: dlopen(libpng.dylib, 2): image not found
所以有人可以帮忙吗?
请您参考如下方法:
也许 pygame 无法加载图像的原因是因为它没有关于从何处加载模块的上下文。确保模块(本质上是您的源代码所在的文件)和图像文件存在于磁盘上的同一环境中(同一文件夹)。否则将绝对路径传递给加载函数并查看是否可以定位图像。
