How to import dateutil?

匆匆过客 提交于 2021-01-28 02:46:21

问题


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:


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

You can check their versions.

pip -V
python -V
pip2 -V

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


来源:https://stackoverflow.com/questions/27005802/how-to-import-dateutil

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!