I am trying to run a program using paster serve
, but I keep getting the error:
ImportError: No module named dateutil.relativedelta
I am running Python version 2.6.7 and dateutil
version 1.5, so it should be installed.
Has anyone got any ideas as to why this would happen?
I am importing using
from dateutil.relativedelta import *
I can even see the package when I search:
/usr/lib/python2.7/site-packages/dateutil/relativedelta.pyc
/usr/lib/python2.7/site-packages/dateutil/relativedelta.py
/usr/lib/python2.7/site-packages/dateutil/relativedelta.pyo
UPDATE
Immediately I look at this and see that dateutil
is only installed for Python 2.7, and I bet what I was doing was this:
sudo yum install python-dateutil
To which sudo
would have switch to the default Python version (i.e., Python 2.7 instead of 2.6.4).
Solving this would have been as simple as:
su
(switch to virtual environment)
yum install python-dateutil
Using su
and then switching to the virtual environment will give root access and install to the virtual Python directory. Using sudo
will install libraries to the default directory, not the virtual environments site-packages.
rpm
is not normally aware of virtual environments. Unless you are gettingpython-dateutil
from a very unusual rpm from a non-standard fedora repository, installing a python package would copy files to the same location regardless of your virtual environment. On the other hand, becoming root (or not) and usingpip
or any other python packaging tool should install in the right place. In fact, most RPM's use this mechanism; but during the build stage, ie, by the package's maintainer. – Mccall