Python新手。问题“六个模块”

时间:2014-07-17 09:58:56

标签: python python-2.7

我正在尝试在Windows 7中运行Eclipse的一段代码,我收到一个错误。

追踪(最近一次呼叫最后一次):

  File "C:\Users\admin\workspace\New\src\test1.py", line 5, in <module>
    import pylab
  File "C:\Python27\lib\site-packages\pylab.py", line 1, in <module>
    from matplotlib.pylab import *
  File "C:\Python27\lib\site-packages\matplotlib\pylab.py", line 226, in <module>
    import matplotlib.finance
  File "C:\Python27\lib\site-packages\matplotlib\finance.py", line 21, in <module>
    from matplotlib.dates import date2num
  File "C:\Python27\lib\site-packages\matplotlib\dates.py", line 119, in <module>
    from dateutil.rrule import (rrule, MO, TU, WE, TH, FR, SA, SU, YEARLY,
  File "C:\Python27\lib\site-packages\dateutil\rrule.py", line 18, in <module>
    from six import advance_iterator, integer_types
ImportError: No module named six

我的源代码是

import numpy
import matplotlib
matplotlib.use('Agg')
from scipy.cluster.vq import *
import pylab
pylab.close()

# generate some random xy points and
# give them some striation so there will be "real" groups.
xy = numpy.random.rand(30,2)
xy[3:8,1] -= .9
xy[22:28,1] += .9

# make some z vlues
z = numpy.sin(xy[:,1]-0.2*xy[:,1])

# whiten them
z = whiten(z)

# let scipy do its magic (k==3 groups)
res, idx = kmeans2(numpy.array(zip(xy[:,0],xy[:,1],z)),3)

# convert groups to rbg 3-tuples.
colors = ([([0,0,0],[1,0,0],[0,0,1])[i] for i in idx])

# show sizes and colors. each color belongs in diff cluster.
pylab.scatter(xy[:,0],xy[:,1],s=20*z+9, c=colors)
pylab.savefig('/var/www/tmp/clust.png')

我是Python的新手,我不知道问题可能是什么。 我使用的是Python 2.7版。

2 个答案:

答案 0 :(得分:1)

很简单 - 您没有安装six。安装它,例如使用pip:

pip install six

答案 1 :(得分:1)

您需要安装模块six,只需使用pip install six

如果你没有pip,你可以从here下载包,解压文件,更改目录 cd six-1.7.3并运行python setup.py install