简体   繁体   English

ImportError:matplotlib需要dateutil; 导入matplotlib.pyplot作为plt

[英]ImportError: matplotlib requires dateutil; import matplotlib.pyplot as plt

Am new to progamming and Python, i keep getting the error below when i run my program. 是编程和Python的新手,运行程序时,我不断收到以下错误消息。 Someone advised i should use pip to solve it. 有人建议我应该使用点子来解决它。 But cant pip get installed using the cmd. 但是无法使用cmd安装点子。 Though i suceeded using Powershell but still cant make it work. 虽然我成功使用Powershell,但仍然无法使其正常工作。 How do i solve this, any tips will go along way. 我该如何解决这个问题,所有技巧都会不断发展。 Thanks 谢谢

Traceback (most recent call last):
  File "<pyshell#0>", line 1, in <module>
    from satmc import satmc
  File "C:\Python27\starb_models_grid1\satmc.py", line 3, in <module>
    import matplotlib.pyplot as plt
  File "C:\Python27\lib\site-packages\matplotlib\__init__.py", line 110, in <module>
    raise ImportError("matplotlib requires dateutil")
ImportError: matplotlib requires dateutil

Am using version 2.7.3 我正在使用2.7.3版

You need to install various packages to get numpy working correctly. 您需要安装各种软件包才能使numpy正常工作。

  1. libsvm-3.17.win32-py2.7 libsvm-3.17.win32-py2.7
  2. pyparsing-2.0.1.win32-py2.7 pyparsing-2.0.1.win32-py2.7
  3. python-dateutil-2.2.win32-py2.7 python-dateutil-2.2.win32-py2.7
  4. pytz-2013.9.win32-py2.7 pytz-2013.9.win32-py2.7
  5. six-1.5.2.win32-py2.7 六-1.5.2.win32-py2.7
  6. scipy-0.13.3.win32-py2.7 scipy-0.13.3.win32-py2.7
  7. numpy-MKL-1.8.0.win32-py2.7 numpy-MKL-1.8.0.win32-py2.7
  8. Matplotlib Matplotlib

Download all the binaries from this link and install and then you will have a working numpy installation. 从此链接下载所有二进制文件并安装,然后您将进行有效的numpy安装。

您可能正在寻找:

pip install python-dateutil

The error states that you are missing Dateutil. 该错误表明您缺少Dateutil。

This could mean that you did not install Dateutil with pip install python-dateutil or your way to install Python modules. 这可能意味着您没有通过pip install python-dateutil安装Dateutil ,也没有安装Python模块的方式。 But if you did your pip install and still get the same error it could also mean that DateUtil is installed in a folder where your Python distribution does not expect it. 但是,如果您进行了pip安装并仍然出现相同的错误,则也可能意味着DateUtil安装在Python发行版不希望的文件夹中。

In my case (Mac OSX) I installed pip with Brew http://brew.sh/ . 就我而言(Mac OSX),我用Brew http://brew.sh/安装了pip。 That pip will install the modules in: /usr/local/lib/python2.7/site-packages/ 该pip将在以下位置安装模块:/usr/local/lib/python2.7/site-packages/

However the standard Mac OSX Python distribution will look for modules in /Library/Python/2.7/site-packages/ 但是,标准Mac OSX Python发行版将在/Library/Python/2.7/site-packages/中查找模块。

Your folders could be different of course, but you can check where Python looks for modules with: 当然,您的文件夹可能有所不同,但是您可以使用以下命令检查Python在哪里寻找模块:

import sys
print sys.path

Check this and see if one of the directories in the list contains the directory where dateutil is installed. 检查此内容,看看列表中的目录之一是否包含安装了dateutil的目录。 If not add a PYTHONPATH environment variable: Like: PYTHONPATH=/usr/local/lib/python2.7/site-packages/ or the folder where your dateutil is installed 如果未添加,则添加PYTHONPATH环境变量:像: PYTHONPATH=/usr/local/lib/python2.7/site-packages/或安装dateutil的文件夹

I did pip install python-dateutil, but kept getting the same error. 我做了pip install python-dateutil,但是一直出现同样的错误。 I got past that error by installing from http://www.lfd.uci.edu/~gohlke/pythonlibs/#python-dateutil Look for the Matplotlib section and install the dependencies you don't have. 通过从http://www.lfd.uci.edu/~gohlke/pythonlibs/#python-dateutil安装,我克服了该错误查找Matplotlib部分并安装您没有的依赖项。 Matplotlib is a 2D plotting library. Matplotlib是2D绘图库。 Requires numpy, dateutil, pytz, pyparsing, six, setuptools, and optionally pillow, pycairo, tornado, wxpython, pyside, pyqt4, ghostscript, miktex, ffmpeg, mencoder, avconv, or imagemagick. 需要numpy,dateutil,pytz,pyparsing,6,setuptools,还可以选择枕头,pycairo,龙卷风,wxpython,pyside,pyqt4,ghostscript,miktex,ffmpeg,mencoder,avconv或imagemagick。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM