简体   繁体   English

``pygame'':在Ubuntu上,使用``pygame.image.save''保存PNG会导致``pygame.error:SavePNG:无法创建png写结构''

[英]`pygame`: on Ubuntu, using `pygame.image.save` to save PNG causes `pygame.error: SavePNG: could not create png write struct`

Error: 错误:

  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

Possible hint A: I am now on Ubuntu. 可能的提示A:我现在在Ubuntu上。 I did not have this issue when running the same script on Windows. 在Windows上运行相同的脚本时,我没有这个问题。

Possible hint B: When pygame.image.save is first called, libpng produces the following warning: 可能提示B:pygame.image.save首次调用, libpng产生以下警告:

libpng warning: Application built with libpng-1.2.51 but running with 1.6.17 libpng警告:使用libpng-1.2.51构建但使用1.6.17运行的应用程序

What should I do to fix this issue? 我应该怎么做才能解决这个问题?

Some things I have tried: 我尝试过的一些方法:

1) can I load PNGs? 1) 我可以加载PNG吗? yes

2) results of python -m pygame.tests : 2) 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

======================================================================
ERROR: GL_ImageSave.test_image_save_works_with_opengl_surfaces
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/brian/anaconda2/lib/python2.7/site-packages/pygame/tests/image__save_gl_surface_test.py", line 37, in test_image_save_works_with_opengl_surfaces
    pygame.image.save(screen, tmp_file)
error: SavePNG: could not create png write struct

======================================================================
ERROR: ImageModuleTest.testSavePNG24
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/brian/anaconda2/lib/python2.7/site-packages/pygame/tests/image_test.py", line 215, in testSavePNG24
    pygame.image.save(surf, f_path)
error: SavePNG: could not create png write struct

======================================================================
ERROR: ImageModuleTest.testSavePNG32
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/brian/anaconda2/lib/python2.7/site-packages/pygame/tests/image_test.py", line 184, in testSavePNG32
    pygame.image.save(surf, f_path)
error: SavePNG: could not create png write struct

======================================================================
ERROR: ImageModuleTest.test_save
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/brian/anaconda2/lib/python2.7/site-packages/pygame/tests/image_test.py", line 248, in test_save
    pygame.image.save(s, temp_filename)
error: SavePNG: could not create png write struct

======================================================================
ERROR: ImageModuleTest.test_save_colorkey
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/brian/anaconda2/lib/python2.7/site-packages/pygame/tests/image_test.py", line 275, in test_save_colorkey
    pygame.image.save(s, temp_filename)
error: SavePNG: could not create png write struct

======================================================================
ERROR: ImageextModuleTest.test_save_unicode_path
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/brian/anaconda2/lib/python2.7/site-packages/pygame/tests/imageext_test.py", line 65, in test_save_unicode_path
    imageext.save_extended(im, temp_file)
error: SavePNG: could not create png write struct

----------------------------------------------------------------------
Ran 708 tests in 28.894s

FAILED (failures=2, errors=6)

The results of these tests makes me think that the issue is unlikely to be due to issues specific to the porting of my code from Windows to Ubuntu (so for instance, I have tried to fix pathnames, etc. wherever possible, and the pygame tests should be platform independent, but still fail?). 这些测试的结果使我认为,该问题不太可能是由于我的代码从Windows移植到Ubuntu所特有的(例如,我已尝试修复路径名等),以及pygame测试应该独立于平台,但仍然失败?)。

This problem was caused because I installed my Python stack using Anaconda , but then installed pygame using the build+install instructions for Ubuntu on pygame 's documentation page . 此问题造成的,因为我使用蟒蛇装我的Python堆栈 ,但随后安装pygame使用内建+上安装Ubuntu的说明pygame的文档页面

This caused there to be conflicting libraries of libpng , I think, somewhere, somehow. 这导致存在libpng库冲突,我认为在某种程度上。

Anyway, the issue was fixed by: 无论如何,此问题已通过以下方式解决:

1) removing pygame (since the instructions I used pip to install pygame, pip uninstall pygame did the trick) 1)删除pygame(由于我使用pip来安装pygame的说明, pip uninstall pygame起到了作用)

2) installing pygame using a build some kind soul had contributed to the conda repositories 2) 使用某种灵魂安装构建 pygame 有助于conda存储库

Then, running python -m pygame.tests reported no errors except for: 然后,运行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

Which I am okay with, for the purposes of this question. 对于这个问题,我可以接受。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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