Ubuntu – not being able to import dateutil module in Python 3

python3

I'm trying to use the Python 3 version of matplotlib module. I am getting errors about dateutil not being present even though I have installed this package. Shouldn't

import dateutil 

work after installing the above package? I am using Ubuntu 14.04 in case it matters.

Best Answer

First make sure that you are not trying to import the module after activating the virtualenv. If you have your virtualenv activated and didn't supply the argument --system-site-packages while creating it, the module won't be available to you to import in virtualenv.

If you are not using a virtualenv and still unable to import the module, then make sure that you are using the Python 3 interpreter and not the Python 2 interpreter. Since you installed the package for python3, it won't be available to import in python2 interpreter. Next try to purge and reinstall the module using:

sudo apt-get purge python3-dateutil
sudo apt-get install python3-dateutil

Purging the package and reinstalling it should fix any issues which was restricting to import the module.