【问题标题】:Install MatPlotLib 1.2.x on OS X Lion 10.7.4 and Python 3.2.2在 OS X Lion 10.7.4 和 Python 3.2.2 上安装 MatPlotLib 1.2.x
【发布时间】:2012-05-13 08:00:56
【问题描述】:

几天前我问了一个关于在同一系统上安装 numpy 的问题。谢天谢地,我自己设法解决了这个问题,但不幸的是,我现在一直在尝试安装 matplotlib。

我首先尝试了当前的分布式版本,但没有运气,所以我想我会下载 git 存储库并尝试一下。我已经走到这一步了:

  • 更改了make.osx 文件,使其可以在 Python 3 中运行:
    • import urllib -> import urllib.request
    • urllib.urlretrieve() -> urllib.request.urlretrieve()

即使在那之后,我仍然无法找到 freetype2 标头。我搜索了一下,发现我可以通过在setupext.py 中编辑一行来解决这个问题:

  • 'darwin' : [], -> 'darwin' : ['/usr/local'],

但是,我在使用 make.osx 文件时仍然收到错误消息。这是我从终端调用文件的方式:

  • sudo make -f make.osx PREFIX=/usr/local PYVERSION=3.2 fetch deps mpl_build mpl_install

我意识到 Python 3 尚未正式支持 matplotlib,但我认为也许某个地方的某个人至少设法让它编译/安装?

任何帮助将不胜感激,

亚当。

我在下面包含了我得到的错误:

basedirlist is: ['/usr/local']
============================================================================
BUILDING MATPLOTLIB
            matplotlib: 1.2.x
                python: 3.2.2 (v3.2.2:137e45f15c0b, Sep  3 2011, 17:28:59)
                        [GCC 4.2.1 (Apple Inc. build 5666) (dot 3)]
              platform: darwin

REQUIRED DEPENDENCIES
                 numpy: 1.6.2rc1
             freetype2: found, but unknown version (no pkg-config)

OPTIONAL BACKEND DEPENDENCIES
                libpng: found, but unknown version (no pkg-config)
               Tkinter: Tkinter: version not identified, Tk: 8.5, Tcl: 8.5
                  Gtk+: no
                        * Building for Gtk+ requires pygtk; you must be able
                        * to "import gtk" in your build/install environment
       Mac OS X native: yes
                    Qt: no
                   Qt4: Qt: 4.7.4, PyQt4: 4.8.6
                PySide: no
                 Cairo: no

OPTIONAL DATE/TIMEZONE DEPENDENCIES
              datetime: present, version unknown
              dateutil: matplotlib will provide
                  pytz: matplotlib will provide
adding pytz

OPTIONAL USETEX DEPENDENCIES
                dvipng: no
           ghostscript: /bin/sh: gs: command not found
                 latex: no

[Edit setup.cfg to suppress the above messages]
============================================================================
pymods ['pylab']
packages ['matplotlib', 'matplotlib.backends', 'matplotlib.backends.qt4_editor', 'matplotlib.projections', 'matplotlib.testing', 'matplotlib.testing.jpl_units', 'matplotlib.tests', 'mpl_toolkits', 'mpl_toolkits.mplot3d', 'mpl_toolkits.axes_grid', 'mpl_toolkits.axes_grid1', 'mpl_toolkits.axisartist', 'matplotlib.sphinxext', 'matplotlib.tri', 'matplotlib.delaunay', 'pytz', 'dateutil', 'dateutil.zoneinfo']
running build
running build_py
copying lib/matplotlib/mpl-data/matplotlibrc -> build/lib.macosx-10.6-intel-3.2/matplotlib/mpl-data
copying lib/matplotlib/mpl-data/matplotlib.conf -> build/lib.macosx-10.6-intel-3.2/matplotlib/mpl-data

running build_ext
building 'matplotlib.ft2font' extension
gcc-4.2 -DNDEBUG -g -O3 -arch i386 -arch x86_64 -I/usr/local/include -I/usr/local/include/freetype2 -isysroot /Developer/SDKs/MacOSX10.6.sdk -DPY_ARRAY_UNIQUE_SYMBOL=MPL_ARRAY_API -DPYCXX_ISO_CPP_LIB=1 -DPYCXX_PYTHON_2TO3=1 -I/usr/local/include -I/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/site-packages/numpy/core/include -I/usr/local/include -I. -I/usr/local/include/freetype2 -I/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/site-packages/numpy/core/include/freetype2 -I/usr/local/include/freetype2 -I./freetype2 -I/Library/Frameworks/Python.framework/Versions/3.2/include/python3.2m -c src/ft2font.cpp -o build/temp.macosx-10.6-intel-3.2/src/ft2font.o
In file included from /Library/Frameworks/Python.framework/Versions/3.2/include/python3.2m/bytearrayobject.h:9,
                 from /Library/Frameworks/Python.framework/Versions/3.2/include/python3.2m/Python.h:73,
                 from ./CXX/WrapPython.h:58,
                 from ./CXX/Extensions.hxx:37,
                 from src/ft2font.h:6,
                 from src/ft2font.cpp:3:
/Developer/SDKs/MacOSX10.6.sdk/usr/include/stdarg.h:4:25: error: stdarg.h: No such file or directory
In file included from /Developer/SDKs/MacOSX10.6.sdk/usr/include/c++/4.2.1/iosfwd:45,
                 from /Developer/SDKs/MacOSX10.6.sdk/usr/include/c++/4.2.1/bits/stl_algobase.h:70,
                 from /Developer/SDKs/MacOSX10.6.sdk/usr/include/c++/4.2.1/bits/char_traits.h:46,
                 from /Developer/SDKs/MacOSX10.6.sdk/usr/include/c++/4.2.1/string:47,
                 from ./CXX/Python3/Exception.hxx:47,
                 from ./CXX/Python3/Objects.hxx:45,
                 from ./CXX/Python3/Extensions.hxx:52,
                 from ./CXX/Extensions.hxx:42,
                 from src/ft2font.h:6,
                 from src/ft2font.cpp:3:
/Developer/SDKs/MacOSX10.6.sdk/usr/include/c++/4.2.1/i686-apple-darwin11/bits/c++locale.h: In function ‘int std::__convert_from_v(int* const&, char*, int, const char*, ...)’:
/Developer/SDKs/MacOSX10.6.sdk/usr/include/c++/4.2.1/i686-apple-darwin11/bits/c++locale.h:77: error: ‘va_start’ was not declared in this scope
/Developer/SDKs/MacOSX10.6.sdk/usr/include/c++/4.2.1/i686-apple-darwin11/bits/c++locale.h:85: error: ‘va_end’ was not declared in this scope
In file included from /Library/Frameworks/Python.framework/Versions/3.2/include/python3.2m/bytearrayobject.h:9,
                 from /Library/Frameworks/Python.framework/Versions/3.2/include/python3.2m/Python.h:73,
                 from ./CXX/WrapPython.h:58,
                 from ./CXX/Extensions.hxx:37,
                 from src/ft2font.h:6,
                 from src/ft2font.cpp:3:
/Developer/SDKs/MacOSX10.6.sdk/usr/include/stdarg.h:4:25: error: stdarg.h: No such file or directory
In file included from /Developer/SDKs/MacOSX10.6.sdk/usr/include/c++/4.2.1/iosfwd:45,
                 from /Developer/SDKs/MacOSX10.6.sdk/usr/include/c++/4.2.1/bits/stl_algobase.h:70,
                 from /Developer/SDKs/MacOSX10.6.sdk/usr/include/c++/4.2.1/bits/char_traits.h:46,
                 from /Developer/SDKs/MacOSX10.6.sdk/usr/include/c++/4.2.1/string:47,
                 from ./CXX/Python3/Exception.hxx:47,
                 from ./CXX/Python3/Objects.hxx:45,
                 from ./CXX/Python3/Extensions.hxx:52,
                 from ./CXX/Extensions.hxx:42,
                 from src/ft2font.h:6,
                 from src/ft2font.cpp:3:
/Developer/SDKs/MacOSX10.6.sdk/usr/include/c++/4.2.1/i686-apple-darwin11/x86_64/bits/c++locale.h: In function ‘int std::__convert_from_v(int* const&, char*, int, const char*, ...)’:
/Developer/SDKs/MacOSX10.6.sdk/usr/include/c++/4.2.1/i686-apple-darwin11/x86_64/bits/c++locale.h:77: error: ‘va_start’ was not declared in this scope
/Developer/SDKs/MacOSX10.6.sdk/usr/include/c++/4.2.1/i686-apple-darwin11/x86_64/bits/c++locale.h:85: error: ‘va_end’ was not declared in this scope
lipo: can't figure out the architecture type of: /var/tmp//ccafJH1l.out
error: command 'gcc-4.2' failed with exit status 1
make: *** [mpl_build] Error 1

【问题讨论】:

  • 你的构建环境不完整吗?有关 stdarg.h 的错误消息表明您缺少头文件。这只是一个猜测,但既然你提到了 Lion,也许你应该在你的 make 命令行上设置 OSX_SDK_VER=10.7。
  • 非常感谢!我将构建目标更改为 10.7,它现在​​可以工作了。再次感谢!

标签: numpy python-3.x matplotlib osx-lion


【解决方案1】:

好的...我想现在已经设法让 ma​​tplotlib 安装...

  1. 首先您需要安装 numpy。我在另一篇文章中有执行此操作的说明:install numpy

  2. 现在打开 Terminal 并克隆 ma​​tplotlib 的 git 存储库(假设您已安装 git):

    • git clone git://github.com/matplotlib/matplotlib.git(这可能需要一段时间)
  3. 克隆完成后,在 Finder

  4. 中打开您的用户文件夹
  5. 在您的用户文件夹中打开 matplotlib 目录

  6. 有一个名为 `make.osx' 的文件用 TextEdit(或类似的)打开它

  7. 更改以下行:

    • MACOSX_DEPLOYMENT_TARGET=10.6
    • OSX_SDK_VER=10.6

    收件人:

    • MACOSX_DEPLOYMENT_TARGET=10.7
    • OSX_SDK_VER=10.7
  8. 更改以下行:

    • ${PYTHON} -c 'import urllib; urllib.urlretrieve("${ZLIBURL}", "${ZLIBFILE}")' &&\ ${PYTHON} -c 'import urllib; urllib.urlretrieve("${PNGURL}", "${PNGFILE}")' &&\ ${PYTHON} -c 'import urllib; urllib.urlretrieve("${FREETYPEURL}", "${FREETYPEFILE}")'

    收件人:

    • ${PYTHON} -c 'import urllib.request; urllib.request.urlretrieve("${ZLIBURL}", "${ZLIBFILE}")' &&\ ${PYTHON} -c 'import urllib.request; urllib.request.urlretrieve("${PNGURL}", "${PNGFILE}")' &&\ ${PYTHON} -c 'import urllib.request; urllib.request.urlretrieve("${FREETYPEURL}", "${FREETYPEFILE}")'
  9. 保存更改

  10. 空闲

  11. 中打开名为setupext.py的文件
  12. 找到'darwin' : [],这一行并将其更改为'darwin' : ['/usr/local'],

  13. 保存文件

  14. 再次打开终端并输入以下内容:

    • sudo make -f make.osx PREFIX=/usr/local PYVERSION=3.2 fetch deps mpl_build mpl_install
  15. 一段时间后,matplotlib 应该安装在以下目录中:

    • /usr/local/lib/Python3.2/site-packages/
  16. 打开上面的目录和下面的目录:

    • /Library/Python/3.2/site-packages/
  17. 将以下目录从/usr/local/lib/Python3.2/site-packages/复制/移动到/Library/Python/3.2/site-packages/

    • dateutil
    • matplotlib
    • mpl_toolkits
  18. ma​​tplotlib 现在应该已安装

  19. 如果您打开 idle 并输入 import matplotlib 它应该不会返回错误

  20. 我试用了matplotlib/examples/user_interfaces/embedding_in_qt4_wtoolbar.py 文件,它似乎工作正常

希望其他人觉得这很有用!

再次感谢您的帮助,

亚当。

【讨论】:

  • 很好地解决了所有这些问题。请前往 matplotlib 邮件列表,帮助他们找出如何让事情变得更简单! ;-)
猜你喜欢
  • 1970-01-01
  • 2012-05-20
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-03-23
  • 2012-04-24
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多