libpng版本在全新安装IPython时不兼容

Mor*_*enB 16 macos homebrew ipython

我使用本指南为Python安装了"科学堆栈"(OSX 10.9.2,brewed Python 2.7.6,IPython 2.0,matplotlib 1.3.1,libpng 1.6.10).一切都很好看.

但是,试图在IPython的笔记本环境中运行一个简单的情节--pylab=inline给我这个错误:

/usr/local/Cellar/python/2.7.6/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/IPython/core/formatters.py:239: FormatterWarning: Exception in image/png formatter: Could not create write struct FormatterWarning,

在终端中它说: libpng warning: Application built with libpng-1.5.17 but running with 1.6.10

据我所知,我没有安装其他libpng.我尝试删除所有以libpngfrom 开头的文件/usr/local/并重新安装所有内容,但无济于事.构建matplotlib(pip install matplotlib)的输出包含:

BUILDING MATPLOTLIB
            matplotlib: yes [1.3.1]
                python: yes [2.7.6 (default, Mar 16 2014, 15:04:47)  [GCC
                        4.2.1 Compatible Apple LLVM 5.1 (clang-503.0.38)]]
              platform: yes [darwin]

REQUIRED DEPENDENCIES AND EXTENSIONS
                 numpy: yes [version 1.8.1]
              dateutil: yes [using dateutil version 2.2]
               tornado: yes [using tornado version 3.2]
             pyparsing: yes [using pyparsing version 2.0.1]
                 pycxx: yes [Couldn't import.  Using local copy.]
                libagg: yes [pkg-config information for 'libagg' could not
                        be found. Using local copy.]
              freetype: yes [version 17.2.11]
                   png: yes [version 1.6.10]

OPTIONAL SUBPACKAGES
           sample_data: yes [installing]
              toolkits: yes [installing]
                 tests: yes [using nose version 1.3.1]

OPTIONAL BACKEND EXTENSIONS
                macosx: yes [installing, darwin]
                qt4agg: yes [installing, Qt: 4.8.6, PyQt4: 4.10.4]
               gtk3agg: no  [Requires pygobject to be installed.]
             gtk3cairo: no  [Requires cairo to be installed.]
                gtkagg: no  [Requires pygtk]
                 tkagg: yes [installing, version 81008]
                 wxagg: no  [requires wxPython]
                   gtk: no  [Requires pygtk]
                   agg: yes [installing]
                 cairo: no  [cairo not found]
             windowing: no  [Microsoft Windows only]

OPTIONAL LATEX DEPENDENCIES
                dvipng: no
           ghostscript: no
                 latex: no
               pdftops: no
Run Code Online (Sandbox Code Playgroud)

所以在我看来,matplotlib应该针对libpng 1.6.10编译?有人可以帮我弄清楚发生了什么吗?

小智 22

@ glenn-randers-pehrson提供的答案的扩展:

pip uninstall matplotlib
cd /opt/X11/include/libpng15
mv png.h _png.h
mv pngconf.h _pngconf.h
mv pnglibconf.h _pnglibconf.h
pip install matplotlib
(if needed remove the old directory or use the force option)

(now move the .h files back to their original locations)
Run Code Online (Sandbox Code Playgroud)


Gle*_*son 14

查找以"png"开头的旧头文件(png.h,pngconf.h,或许是其他文件)并删除它们.


xbs*_*bsd 8

为了记录(从以上评论开始):

删除X11

launchctl unload /Library/LaunchAgents/org.macosforge.xquartz.startx.plist
sudo launchctl unload /Library/LaunchDaemons/org.macosforge.xquartz.privileged_startx.plist
sudo rm -rf /opt/X11* /Library/Launch*/org.macosforge.xquartz.* /Applications/Utilities/XQuartz.app /etc/*paths.d/*XQuartz
sudo pkgutil --forget org.macosforge.xquartz.pkg
Run Code Online (Sandbox Code Playgroud)

然后,

如果安装了matplotlib/python,请根据需要运行以下命令:

pip uninstall matplotlib
pip uninstall ipython
Run Code Online (Sandbox Code Playgroud)

然后,

pip install matplotlib
pip install ipython
Run Code Online (Sandbox Code Playgroud)

如有必要,可以从https://www.macupdate.com/app/mac/26593/xquartz重新安装XQuartz .

[注意:这会重新添加/opt/X11/include/libpng15/png.h等文件,但之后ipython工作正常.]