安装Matplot Lib Mac - Mavericks - 错误pyplot

时间:2014-10-12 17:34:55

标签: python macos python-2.7 matplotlib

我尝试过多种方式安装matplotlib并且我成功使用 - 通过github下载,将目录更改为文件夹,以及运行sudo python setup.py install。但是,pyplot没有工作,所以我卸载了,我正在尝试使用pip并且遇到了大量的错误。

Megans-MacBook-Pro:~ MeganRCunninghan$ sudo pip install matplotlib
Downloading/unpacking matplotlib
  Running setup.py egg_info for package matplotlib
    ============================================================================
    Edit setup.cfg to change the build options

    BUILDING MATPLOTLIB
                matplotlib: yes [1.4.0]
                    python: yes [2.7.5 (default, Mar  9 2014, 22:15:05)  [GCC
                            4.2.1 Compatible Apple LLVM 5.0 (clang-500.0.68)]]
                  platform: yes [darwin]

    REQUIRED DEPENDENCIES AND EXTENSIONS
                     numpy: yes [version 1.6.2]
                       six: yes [six was not found.]
                  dateutil: yes [using dateutil version 1.5]
                   tornado: yes [tornado was not found. It is required for the
                            WebAgg backend. pip/easy_install may attempt to
                            install it after matplotlib.]
                 pyparsing: yes [pyparsing was not found. It is required for
                            mathtext support. pip/easy_install may attempt to
                            install it after matplotlib.]
                     pycxx: yes [Couldn't import.  Using local copy.]
                    libagg: yes [pkg-config information for 'libagg' could not
                            be found. Using local copy.]
    Traceback (most recent call last):
      File "<string>", line 16, in <module>
      File "/tmp/pip-build/matplotlib/setup.py", line 154, in <module>
        result = package.check()
      File "setupext.py", line 940, in check
        if 'No such file or directory\ngrep:' in version:
    TypeError: argument of type 'NoneType' is not iterable
    Complete output from command python setup.py egg_info:
    ============================================================================

Edit setup.cfg to change the build options



BUILDING MATPLOTLIB

            matplotlib: yes [1.4.0]

                python: yes [2.7.5 (default, Mar  9 2014, 22:15:05)  [GCC

                        4.2.1 Compatible Apple LLVM 5.0 (clang-500.0.68)]]

              platform: yes [darwin]



REQUIRED DEPENDENCIES AND EXTENSIONS

                 numpy: yes [version 1.6.2]

                   six: yes [six was not found.]

              dateutil: yes [using dateutil version 1.5]

               tornado: yes [tornado was not found. It is required for the

                        WebAgg backend. pip/easy_install may attempt to

                        install it after matplotlib.]

             pyparsing: yes [pyparsing was not found. It is required for

                        mathtext support. pip/easy_install may attempt to

                        install it after matplotlib.]

                 pycxx: yes [Couldn't import.  Using local copy.]

                libagg: yes [pkg-config information for 'libagg' could not

                        be found. Using local copy.]

Traceback (most recent call last):

  File "<string>", line 16, in <module>

  File "/tmp/pip-build/matplotlib/setup.py", line 154, in <module>

    result = package.check()

  File "setupext.py", line 940, in check

    if 'No such file or directory\ngrep:' in version:

TypeError: argument of type 'NoneType' is not iterable

----------------------------------------
Command python setup.py egg_info failed with error code 1 in /tmp/pip-build/matplotlib
Storing complete log in /Users/MeganRCunninghan/Library/Logs/pip.log

当我去python并输入

>>import matplot lib 

它可以工作,但是当我想要matplotlib.pyplot时,我收到一个错误:

>>> import matplotlib.pyplot as plt

Traceback (most recent call last):
  File "<pyshell#3>", line 1, in <module>
    import matplotlib.pyplot as plt
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/pyplot.py", line 26, in <module>
    from matplotlib.figure import Figure, figaspect
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/figure.py", line 24, in <module>
    import matplotlib.artist as martist
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/artist.py", line 7, in <module>
    from transforms import Bbox, IdentityTransform, TransformedBbox, \
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/transforms.py", line 35, in <module>
    from matplotlib._path import (affine_transform, count_bboxes_overlapping_bbox,
ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/_path.so, 2): no suitable image found.  Did find:
    /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/_path.so: no matching architecture in universal wrapper

2 个答案:

答案 0 :(得分:1)

我强烈建议您安装Anaconda。它解决了安装科学相关模块时出现的许多问题。

答案 1 :(得分:0)

所以我解决了这个问题: 通过python中定位的安装目录手动卸载matplotlib:

>>> import matplotlib
>>> matplotlib.__file__

然后我去了我的finder并使用CMD + Shift + G找到了文件夹并粘贴了给定的文件位置。 选择matplotlib文件并删除。 去了cmd行并输入了

sudo pip install matplotlib

现在它有效。 另外,在运行pip之前我安装了xcode并使用这些说明修复了clang和lipo之间的挂断: 安装xcode,转到termina -

 xcode-select --install

在以下位置安装命令行工具:https://developer.apple.com/downloads/index.action?=command%20line%20tools#

转到终端:

sudo mv /usr/bin/lipo /usr/bin/lipo.orig sudo 
ln -s /Library/Developer/CommandLineTools/usr/bin/lipo /usr/bin

如果您没有Pip,请安装Pip:

sudo su 
easy_install pip