My python 2.7 code is as follows:
import pandas as pd
from pandas import DataFrame
DF_rando = DataFrame([1,2,3])
...and then when I execute, I get a strange error regarding dateutil.tz
.
/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7 /Users/mattobrien/pandas_test.py
No module named dateutil.tz
Traceback (most recent call last):
File "/Users/mattobrien/pandas_test.py", line 2, in <module>
import pandas as pd
File "/Library/Python/2.7/site-packages/pandas/__init__.py", line 7, in <module>
from . import hashtable, tslib, lib
File "pandas/tslib.pyx", line 37, in init pandas.tslib (pandas/tslib.c:76999)
ImportError: No module named dateutil.tz
Process finished with exit code 1
Very strange. I checked an indeed dateutil.tz
is indeed installed. I uninstalled Pandas
and reinstalled it to be sure. No issues there.
Why am I getting this error?
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 Python "ModuleNotFoundError: No module named 'dateutil'" occurs when we forget to install the python-dateutil module before importing it or install it in an incorrect environment. To solve the error, install the module by running the pip install python-dateutil command.
Needed these 2 lines.
sudo pip install python-dateutil --upgrade
sudo pip install pytz --upgrade
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