【昊鼎王五】执行python3脚本,报“ModuleNotFoundError: No module named ‘dateutil’”错的解决方法

报错信息

[root@centos tmp]# python W1.py 
W1.py:4: DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated, and in 3.8 it will stop working
  import pymssql
Traceback (most recent call last):
  File "W1.py", line 8, in <module>
    from dateutil import parser
ModuleNotFoundError: No module named 'dateutil'

如下图:
在这里插入图片描述

分析

很明显,是dateutil模块没有找到。所以解决方法就是用pip工具将此模块给安装上。

解决命令

命令如下:

pip3 install dateutil

查看效果,报错
[root@centos tmp]# pip install dateutil
ERROR: Could not find a version that satisfies the requirement dateutil (from versions: none)
ERROR: No matching distribution found for dateutil
在这里插入图片描述
与我们预期结果不符,到底该怎么办呢?

经过查阅资料,发现该模块的全称是:“python-dateutil”
正确的安装该模块的命令如下:

pip3 install python-dateutil

效果如图:
在这里插入图片描述

回到主题

再来执行我们的python脚本,看看效果吧,果然没有报错了。

好了,聪明如你,就讲到这里吧,有问题的话可以留言。
在这里插入图片描述

Logo

汇聚全球AI编程工具,助力开发者即刻编程。

更多推荐