【问题标题】:libpng version incompatibility in fresh installation of IPython全新安装 IPython 中的 libpng 版本不兼容
【发布时间】:2014-04-06 18:38:55
【问题描述】:

我使用this guide 为 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。我尝试从/usr/local/ 中删除以libpng 开头的所有文件并重新安装所有文件,但无济于事。构建 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

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

【问题讨论】:

  • 我应该补充一点,带有 MacOSX 后端图形的标准 IPython 终端环境可以正常工作。
  • 是的!谢谢!我用/opt/X11/include/libpng15/png.h 和其他一些类似的方式安装了 XQuartz。删除它们并重新编译解决了我的问题。
  • 供将来参考:下载 Anaconda 之类的东西可能更容易,它会安装整个 Scipy 堆栈,而不是单独安装所有部分。
  • 我也遇到了同样的问题,你能具体说明你做了什么吗?
  • 我跑了sudo find / -name "png*.h" 来找到@Glenn 提到的头文件。我在/opt/X11 中注意到了一些,它属于 XQuartz。于是我跟着this guide把XQuartz删了,用pip重新安装了matplotlib和ipython。

标签: macos ipython homebrew


【解决方案1】:

@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)

【讨论】:

  • 如果你通过 homebrew 安装 libpng,通过 brew cask 安装 xquartz,你可以暂时卸载 xquartz,安装 matplotlib(它将针对 homebrew 的 libpng 进行编译,然后重新安装 xquartz。
  • 有必要把它们移回去吗?
  • 这个解决方案对我有用,我从不费心将 .h 文件移回原来的位置。
【解决方案2】:

查找以“png”开头的旧头文件(png.h、pngconf.h,也许还有其他)并删除它们。

【讨论】:

    【解决方案3】:

    为了记录(从上面的 cmets 开始):

    移除 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
    

    那么,

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

    pip uninstall matplotlib
    pip uninstall ipython
    

    那么,

    pip install matplotlib
    pip install ipython
    

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

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

    【讨论】:

      【解决方案4】:

      虽然 有多个 libpng 副本有点荒谬,但这个问题是由于 pip 编译器和 python 的路径不同造成的。你也可以通过路径修复这个问题,然后重新编译,不过上面的解决方案也可以。

      【讨论】:

        猜你喜欢
        • 2016-04-18
        • 2018-07-29
        • 2020-03-25
        • 1970-01-01
        • 1970-01-01
        • 2019-08-04
        • 1970-01-01
        • 2021-03-24
        • 1970-01-01
        相关资源
        最近更新 更多