Matplotlib Mac OSX Yosemite 10.10.1

时间:2014-11-25 19:40:43

标签: python matplotlib

我最近刚从一本书中学习Matplotlib,并且遇到了一些安装问题。

我下载了1.4.2源码,更改了第961行setupext.py,用于freetype依赖,然后编译,并安装在(env)中。

pip冻结给出了(env)的基本要求。

matplotlib==1.4.2
mock==1.0.1
nose==1.3.4
numpy==1.9.1
pyparsing==2.0.3
python-dateutil==2.2
pytz==2014.9
six==1.8.0
wsgiref==0.1.2

我有一个名为data_plot.py

的文件
#!/usr/bin/python
from __future__ import print_function
from __future__ import division
from __future__ import absolute_import

import numpy as np
import matplotlib.pyplot as plt

# create x, randomly spaced between 0 to 20
x = np.linspace(0,20,10)

当运行python data_plot.py时,它似乎陷入困境。

stuck thinking

控制台应该从0-20正确吐出10个随机数?我编译完全错了吗?我将所有文件上传到github

1 个答案:

答案 0 :(得分:3)

所以我一直在教授使用matplotlib和其他一些python pacakges(NumPy,SciPy,Scikit-learn)的课程,并且必须在几台机器上安装matplot lib。

这些是我创建的安装说明,以确保您为OS X Yosemite正确安装了matplotlib。我强烈建议你做所有的步骤。

  1. 确保安装了命令行工具,为此在终端中键入以下内容:       
    sudo xcode select --install
  2. 确保已安装GCC。这些是通过home brew安装GCC的说明。第一条线安装家酿,第二条GCC。       

    ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
    sudo brew install gcc

  3. 确保已安装pip       

    sudo easy_install pip

  4. 现在安装你的软件包,如果你还没有它,我建议你购买NumPy和SciPy以及matplotlib。       

    sudo pip install -U numpy
    sudo pip install -U scipy
    sudo pip install -U matplotlib


  5. 我还试过运行上面的代码,输出如下:

    jonhurlock~$:python
    Python 2.7.6 (default, Sep  9 2014, 15:04:36) 
    [GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.39)] on darwin
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import numpy as np
    >>> import matplotlib.pyplot as plt
    >>> 
    >>> # create x, randomly spaced between 0 to 20
    ... x = np.linspace(0,20,10)
    >>> print x
    [  0.           2.22222222   4.44444444   6.66666667   8.88888889
      11.11111111  13.33333333  15.55555556  17.77777778  20.        ]
    >>> 
    
相关问题