I am trying to run a program using paster serve
, but I keep getting the error:
ImportError: No module named dateutil.relativedelta
I had a similar issue but for a simpler reason. My fresh virtualenv simply didn't have dateutil installed and I didn't know the Python package name. I tried pip install dateutil
, which obviously didn't work since the package name was incorrect. Running pip install python-dateutil
instead worked (without resorting to sudo
).
This looks like a problem of package installation to me. A troubleshooting list that comes to my mind:
I also ran into this issue. The simple solution I ended up using was to add --upgrade
to the end of the command. This forced it to install it even though Python thought it was installed. This resolved the issue.
So if you have this issue, try the following:
sudo pip install python-dateutil --upgrade
It can't possibly hurt anything, so there is no harm in just forcing it to be reinstalled.
(The previous comment about installing python-dateutil helped me, so perhaps my comment helps someone else).
For those on Mac OS (v10.6 (Snow Leopard); I am not sure about other versions), the dateutils package is located by default at:
/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/dateutil
whereas pip install writes the package out to:
/Library/Python/2.6/site-packages
and does not update the /Library/Python/2.6/site-packages/easy-install.pth file. As a result, when you import dateutil, you will still point to the old location, you can verify this by "import dateutil; dateutil.__file__
".
So what I did (probably better methods are available) was to rename the old directory (/System/Library/.../dateutil
) to dateutil.obsolete
and restarted Python, then ran the same set of commands again. This doesn't do anything to the path file or sys.path
, but skips the old dateutils package so you can get to the new one.