问题
import pygame
works fine for me, but import pygame.font
fails with the error:
ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pygame/font.so, 2): Library not loaded: /usr/local/lib/libpng15.15.dylib
Referenced from: /usr/local/lib/libfreetype.6.dylib
Reason: Incompatible library version: libfreetype.6.dylib requires version 30.0.0 or later, but libpng15.15.dylib provides version 20.0.0
This is in Python 2.7 (not the system version), Mac OS 10.9. I installed libpng-1.6.9 on the idea that libfreetype wanted a later version, but that didn't seem to help.
回答1:
What happened was libpng wasn’t installed as a dependency for some reason. So I grabbed the 64 bit Mac OS X binary at http://www.libpng.org/pub/png/libpng.html. But the version was 1.5.4, which is old.
To resolve this, I deleted all of the libpng15 files from usr/local/lib then downloaded the source for 1.5.18 from http://sourceforge.net/projects/libpng/files/libpng15/1.5.18/ and:
./configure [--prefix=/path]
make check
make install
to install.
Issue resolved. I am going to leave this here in case others have the same problem, since I googled the error quite a bit and couldn’t find a solution.
来源:https://stackoverflow.com/questions/22030935/failure-on-import-pygame-font