本文介绍了安装Pylab/Matplotlib的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

我正在尝试编写一个绘制图形的程序,这让我开始研究Matplotlib.

I'm trying to write a program that plots a graph, which made me look intoMatplotlib.

我找到了一个以这个小程序开始的教程,效果很好:

I found a tutorial that started out with this little program, that worked fine:

from pylab import *

def main():
    X = np.linspace(-np.pi, np.pi, 256, endpoint=True)
    C,S = np.cos(X), np.sin(X)
    plot(X,C)
    plot(X,S)
    show()

if __name__ == '__main__':
    main()

然后我尝试在另一台计算机上运行它,但它根本无法运行.我尝试下载 Pylab 和 Matplotlib.当我安装Matplotlib时,它需要一个叫做dateutil的东西,当我获得dateutil时,它需要叫做6的东西.我下载了六个,但无法正常工作.

Then I tried to run it on another computer, where it did not work at all. I tried to download Pylab and Matplotlib. When I had installed Matplotlib it demanded something called dateutil, when I got dateutil it demanded something called six. I downloaded six, but it didn't work properly.

感觉好像我没有走在正确的轨道上.我应该怎么做才能正确安装?

It doesn't feel like I'm on the right track. What should I do to get a proper installation?

我正在Windows 7上使用Python 2.7.

I'm using Python 2.7 on Windows 7.

我得到的错误是

Traceback (most recent call last):
  File "C:\Users\Python\mscript\listdb2.py", line 19, in <module>
    from pylab import *
  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

文件 Six.py 位于 C:\python27\Lib\site-packages\six\six.py

The file six.py is located in C:\python27\Lib\site-packages\six\six.py

六目录还包含一个名为 test_six.py 的文件.如果我尝试运行该程序,也会收到错误消息:

The six directory also contains a file called test_six.py. If I try to run this program I also get an error:

Traceback (most recent call last):
  File "test_six.py", line 5, in <module>
    import.py
ImportError: No module named py

推荐答案

如果安装了 Anaconda 并且它已经在您的环境路径中,您只需使用

If Anaconda installed and it is already in your environment path, you can get it simply using

conda install matplotlib

在命令行中,然后在 Python 中调用

in command line and then call in Python with

from pylab import *

这对我来说很好,因为 Win 和 Linux 上的pip install"和easy_install"导致了很多问题

This work for me fine as "pip install" and "easy_install" both on Win and Linux caused a lot of issues

这篇关于安装Pylab/Matplotlib的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-08 10:23