ImportError: No module named dateutil
Solution 1
That's strange, since you say you can see it as installed with pip
.
I've just run pip freeze | grep date
and here's what I get:
python-dateutil==1.5
Is your response something similar? Having run the following:
$ python
>>> import dateutil
>>> help(dateutil)
I am told that my dateutil
module is installed in /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/dateutil/__init__.py
(OS X). I would check your Python install to make sure nothing went wrong. There shouldn't be a need to install it separately, but you could perhaps use pip to uninstall then reinstall
Solution 2
Had the same issue with Python3, even though when I tried installing it, a message said it already was. So the fix was:
sudo pip3 uninstall python-dateutil
sudo pip3 install python-dateutil
As suggested here.
user2406467
Updated on July 24, 2022Comments
-
user2406467 almost 2 years
I am trying to follow the example in the "First Steps with Celery" document. I have installed Celery using pip.
I created a file called tasks.py in ~/python/celery, and it contains the following:
from celery import Celery celery = Celery('tasks', broker='amqp://guest@localhost//') @celery.task def add(x, y): return x + y
I started a worker using celery -A tasks worker --loglevel=info while in the ~/python/celery directory, and it seems to be running.
In a separate Terminal window, I launched Python and ran the following:
from tasks import add add.delay(4, 4)
I get the error: File "/Library/Python/2.7/site-packages/celery/utils/timeutils.py", line 17, in from dateutil import tz ImportError: No module named dateutil
How do I install dateutils? It is listed as an installed module when I type "pip freeze"
Thanks!
-
user2406467 about 11 yearsWhen I run pip freeze | grep date, I got the exact result you did. When I tried import dateutil, Python still gave me an error. I ended up installing dateutil from the tar.gz, and everything works now. Your hint to check the install dir was helpful. Thanks!
-
Blake about 10 yearsI also ran into this issue, pip told me it was installed but python complained. easy_install python-dateutil and easy_install tzlocal fixed the issue.