`pygame`: on Ubuntu, using `pygame.image.save` to save PNG causes `pygame.error: SavePNG: could not create png write struct`
`pygame`: on Ubuntu, using `pygame.image.save` to save PNG causes `pygame.error: SavePNG: could not create png write struct`
错误:
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
的结果:
======================================================================
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)
这些测试的结果让我认为这个问题不太可能是由于我的代码从 Windows 移植到 Ubuntu 的特定问题(例如,我试过尽可能修复路径名等,pygame
测试应该独立于平台,但仍然失败?)。
这个问题是因为 I installed my Python stack using Anaconda, but then installed pygame
using the build+install instructions for Ubuntu on pygame
's documentation page.
我认为,这导致 libpng
的库存在冲突,不知何故。
无论如何,问题已解决:
1) 删除 pygame(因为我使用 pip
安装 pygame 的说明,pip uninstall pygame
成功了)
2) 安装 pygame
using a build some kind soul had contributed to the conda
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
为了这个问题的目的,我同意。
错误:
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
的结果:
======================================================================
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)
这些测试的结果让我认为这个问题不太可能是由于我的代码从 Windows 移植到 Ubuntu 的特定问题(例如,我试过尽可能修复路径名等,pygame
测试应该独立于平台,但仍然失败?)。
这个问题是因为 I installed my Python stack using Anaconda, but then installed pygame
using the build+install instructions for Ubuntu on pygame
's documentation page.
我认为,这导致 libpng
的库存在冲突,不知何故。
无论如何,问题已解决:
1) 删除 pygame(因为我使用 pip
安装 pygame 的说明,pip uninstall pygame
成功了)
2) 安装 pygame
using a build some kind soul had contributed to the conda
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
为了这个问题的目的,我同意。