Hello I am trying to use relativedelta
from the dateutil
module.
I want to do what is mentioned here, add some months to a given datetime
object.
But I'm trying to use Python 3 for this and I am getting the following error:
Traceback (most recent call last):
File "bin/controller.py", line 2, in <module>
from dateutil.relativedelta import relativedelta
ImportError: No module named 'dateutil'
I then read that dateutil is now part of Python 3 but how do I import it?
import dateutil
does not seem to work:
Traceback (most recent call last):
File "bin/controller.py", line 3, in <module>
import dateutil
ImportError: No module named 'dateutil'
I am using a virtualenv so I would like to install it with pip
.
The relativedelta type is designed to be applied to an existing datetime and can replace specific components of that datetime, or represents an interval of time. It is based on the specification of the excellent work done by M. -A. Lemburg in his mx. DateTime extension.
Python 2. x has an extraordinary function called dateutil. parser which transforms an ISO8601 arranged date into a python DateTime value. It's absent in Python 3.
The dateutil module specializes in providing an extension of features to the existing datetime module, and as such, the installation of the datetime module is a prerequisite. However, since it's a part of the Python standard library, there's nothing to worry about.
It seems you have to pip-install it like this and it works :
pip install python-dateutil
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With