`pygame`:在Ubuntu上,使用`pygame.image.save`保存PNG原因`pygame.error.错误:SavePNG:无法创建png write结构`

2024-09-28 13:30:43 发布

您现在位置:Python中文网/ 问答频道 /正文

错误:

  File "/home/alien/cncell/core/animator.py", line 413, in create_animation_from_data
    pygame.image.save(screen, image_fp)
pygame.error: SavePNG: could not create png write struct

可能的提示A:我现在在Ubuntu上。我在Windows上运行相同的脚本时没有这个问题。在

可能的提示B:当第一次调用pygame.image.save时,libpng生成以下警告:

libpng warning: Application built with libpng-1.2.51 but running with 1.6.17

我该怎么解决这个问题?在

我试过的一些事情:

1)我可以加载PNG吗?是的

2)python -m pygame.tests结果:

^{pr2}$

这些测试的结果让我认为这个问题不太可能是由于我的代码从Windows移植到Ubuntu的特定问题造成的(例如,我试图修复路径名等,只要有可能,pygame测试应该是独立于平台的,但仍然失败吗?)。在


Tags: coreimagehomeubuntuwindowssave错误create
1条回答
网友
1楼 · 发布于 2024-09-28 13:30:43

这个问题是由于I installed my Python stack using Anaconda引起的,但是installed ^{} using the build+install instructions for Ubuntu on ^{}'s documentation page。在

这导致了libpng的冲突库,我想,不知怎么的。在

无论如何,这个问题是通过以下方式解决的:

1)删除pygame(因为我使用pip来安装pygame,pip uninstall pygame完成了这个任务)

2)安装pygameusing a build some kind soul had contributed to the ^{} repositories

然后,运行python -m pygame.tests时没有报告任何错误,除了:

======================================================================
FAIL: BaseModuleTest.test_get_error
                                   
Traceback (most recent call last):
  File "/home/brian/anaconda2/lib/python2.7/site-packages/pygame/tests/base_test.py", line 569, in test_get_error
    e)
AssertionError: Failed to access the SoundFont /usr/share/sounds/sf2/FluidR3_GM.sf2

======================================================================
FAIL: BaseModuleTest.test_set_error
                                   
Traceback (most recent call last):
  File "/home/brian/anaconda2/lib/python2.7/site-packages/pygame/tests/base_test.py", line 586, in test_set_error
    e)
AssertionError: Failed to access the SoundFont /usr/share/sounds/sf2/FluidR3_GM.sf2

为了这个目的,我是可以的。在

相关问题 更多 >

    热门问题