How to import dateutil?

9.7k views Asked by At

I am missing something obviously simple here, but I can't say what : I need your fresh eyes to tell me :)

$ pip install python-dateutil
Requirement already satisfied (use --upgrade to upgrade): python-dateutil in /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python
Cleaning up...
$ python
Python 2.7.6 (v2.7.6:3a1db0d2747e, Nov 10 2013, 00:42:54) 
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
>>> import dateutil
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named dateutil

How to import dateutils ??

1

There are 1 answers

0
蔡宗容 On

The root cause might be that python and pip do not match.

You can check their versions.

pip -V
python -V
pip2 -V

check the version

As you can see, python and pip do not match. pip is for python3 and python is for python2.

Hence, the solution should be

pip2 install python-dateutil