据我所知,对于我要做的事情,我甚至不需要使用pytz。
我正在重新学习Python以进行图像处理,使用O'Reilly书籍“Programming Computer Vision with Python”进行工作(我还是新手Mac用户,因此在这两个方面都很抱歉,如果这是一个愚蠢的问题)。 除了一张名为'empire.jpg'的图片外,我还尝试在第16页运行以下脚本:
from PIL import Image
from pylab import *
# read image to array
im = array(Image.open('empire.jpg')) # plot the image
imshow(im)
# some points
x = [100,100,400,400]
y = [200,500,200,500]
# plot the points with red star-markers
plot(x,y,'r*')
# line plot connecting the first two points
plot(x[:2],y[:2])
# add title and show the plot
title('Plotting: "empire.jpg"')
show()
但是我得到了以下带有错误的输出:
File "plotch1.py", line 2, in <module>
from pylab import *
File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/pylab.py", line 1, in <module>
from matplotlib.pylab import *
File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/matplotlib/pylab.py", line 208, in <module>
from matplotlib import mpl # pulls in most modules
File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/matplotlib/mpl.py", line 4, in <module>
from matplotlib import axes
File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/matplotlib/axes.py", line 18, in <module>
from matplotlib import dates as mdates
File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/matplotlib/dates.py", line 82, in <module>
import pytz
ImportError: No module named pytz
我正在使用OS X 10.9.4。我从macpython.org安装了matplotlib和numpy,并安装了适用于Python 2.5的scipy 0.11.0。
我是否需要pytz?如果不需要,我该如何解决这个错误?
matplotlib
需要pytz
;只需安装该软件包即可? - Martijn Pieters