Question

I just installed the following onto my Win 7 machine running an AMD A8-5600K APU (64-bit Operating System

python-2.7.6.msi
matplotlib-1.3.1.win32-py2.7.exe
numpy-1.8.0-win32-superpack-python2.7.exe

When I use

import numpy as np
import matplotlib.pyplot as plt
import matplotlib.animation as animation

I get this error message:

Traceback (most recent call last): 
  File "C:\Python27\MuirsProgs\decay-1.py", line 9, in <module> 
    import matplotlib.pyplot as plt 
  File "C:\Python27\lib\site-packages\matplotlib_init_.py", line 111, in <module> 
    raise ImportError("matplotlib requires dateutil") 
ImportError: matplotlib requires dateutil

I am new to Python and have no idea of how to fix this.

Was it helpful?

Solution

If you examine the actual error message you got, you'll see that matplotlib requires the dateutil module. It actually requires a few other modules as well, and has optional dependencies on several more. The easiest way to install many scientific computing and other modules on Windows is to visit Christoph Gohlke's excellent Python Extension Packages for Windows repository and have a look around to see if your module of interest is there. Many of them are linked to a version of NumPy compiled with Intel's Math Kernel Library (MKL) for increased performance.

If you go down to the matplotlib section, you'll find the list of required and optional dependencies, including numpy, dateutil, pytz, pyparsing, and six. I'd also recommend getting Pillow and tornado as well as your favorite graphics backend (I use pyqt). Just follow the links to the other sections of the repository, and download the appropriate files for your version and bit-ness of Python. I'd recommend re-downloading the MKL-linked NumPy installer, even though you have an AMD processor, as many of the other packages rely on it, and it will gracefully degrade if your particular processor doesn't have all the features an Intel one might. I'd also recommend re-downloading the matplotlib installer as well, just so all your modules have come from the same source, and will play together as nicely as possible. If you want to, beforehand, go to C:\Python27\Lib\site-packages and delete the numpy and matplotlib directories, as well as any other files/directories with related names. If you haven't installed any other third-party modules at all except those two, then just delete all contents of the site-packages directory and you should be fine.

Good luck!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top