我目前正在练习matplotlib。这是我练习的第一个示例。
#!/usr/bin/python
import matplotlib.pyplot as plt
radius = [1.0, 2.0, 3.0, 4.0]
area = [3.14159, 12.56636, 28.27431, 50.26544]
plt.plot(radius, area)
plt.show()
当我使用运行脚本时python ./plot_test.py
,它可以正确显示绘图。但是,我自己运行./plot_test.py
,它引发了以下问题:
Traceback (most recent call last):
File "./plot_test.py", line 3, in <module>
import matplotlib.pyplot as plt
ImportError: No module named matplotlib.pyplot
python是否在不同位置查找matplotlib?
环境是:
Mac OS X 10.8.4 64bit
built-in python 2.7
numpy,scipy,matplotlib已安装:
sudo port install py27-numpy py27-scipy py27-matplotlib \
py27-ipython +notebook py27-pandas py27-sympy py27-nose