Unable to import required dependencies: pytz: No module named ‘pytz‘ ,dateutil: No module named【已解决】

93 篇文章 4 订阅
7 篇文章 0 订阅
在尝试运行程序时遇到了ImportError,提示缺少pytz和dateutil模块。尝试使用pip安装这两个模块失败,后发现是由于版本匹配问题。通过卸载并重新安装matplotlib,意外地解决了问题,因为matplotlib安装时会伴随安装python-dateutil。
摘要由CSDN通过智能技术生成

问题描述

执行程序时候报错如下:

Exception has occurred: ImportError

Unable to import required dependencies: pytz: No module named 'pytz' dateutil: No module named 'dateutil'

File "E:\matlab\CHB-MIT-DATA\epilepsy_eeg_classification\preprocessing.py", line 13, in <module> import pandas as pd ImportError: Unable to import required dependencies: pytz: No module named 'pytz' dateutil: No module named 'dateutil'

 直接安装

pip install --upgrade pytz

pip install --upgrade dateutil

Exception has occurred: ImportError

Unable to import required dependencies: dateutil: No module named 'dateutil'

File "E:\matlab\CHB-MIT-DATA\epilepsy_eeg_classification\preprocessing.py", line 13, in <module> import pandas as pd ImportError: Unable to import required dependencies: dateutil: No module named 'dateutil'

这个dateutil安装不上,直到找到了这个

python安装提示错误Could not find a version that satisfies the requirement dateutil - ytkah - 博客园

(cat) PS E:\matlab> pip install --upgrade dateutil
ERROR: Could not find a version that satisfies the requirement dateutil (from versions: none)
ERROR: No matching distribution found for dateutil
(cat) PS E:\matlab> pip install dateutil
ERROR: Could not find a version that satisfies the requirement dateutil (from versions: none)
ERROR: No matching distribution found for dateutil
(cat) PS E:\matlab> pip3 install python-dateutil
Requirement already satisfied: python-dateutil in d:\program\anaconda3\envs\cat\lib\site-packages (2.8.1) 
Requirement already satisfied: six>=1.5 in d:\program\anaconda3\envs\cat\lib\site-packages (from python-dateutil) (1.16.0)
(cat) PS E:\matlab>

虽然上面安装上了 pip3 install python-dateutil。但是程序运行时候,不认啊。

pandas的必须依赖有dateutil,pip list里面有python-dateutil,仍旧是一个劲儿的报错。

我又找到了一个方法python 2.7安装dateutil 方法 - woxin的个人空间 - OSCHINA - 中文开源技术交流社区,说dateutil也是伴随 matplotlib安装的,所以我先卸载matplotlib,又重新安装。

pip uninstall matplotlib

pip install matplotlib

然后成了,展示如下:

(cat) PS E:\matlab> pip uninstall matplotlib
Found existing installation: matplotlib 3.5.3
Uninstalling matplotlib-3.5.3:
  Would remove:
    d:\program\anaconda3\envs\cat\lib\site-packages\matplotlib-3.5.3-py3.7-nspkg.pth
    d:\program\anaconda3\envs\cat\lib\site-packages\matplotlib-3.5.3.dist-info\*
    d:\program\anaconda3\envs\cat\lib\site-packages\matplotlib\*
    d:\program\anaconda3\envs\cat\lib\site-packages\mpl_toolkits\axes_grid1\*
    d:\program\anaconda3\envs\cat\lib\site-packages\mpl_toolkits\axes_grid\*
    d:\program\anaconda3\envs\cat\lib\site-packages\mpl_toolkits\axisartist\*
    d:\program\anaconda3\envs\cat\lib\site-packages\mpl_toolkits\mplot3d\*
    d:\program\anaconda3\envs\cat\lib\site-packages\mpl_toolkits\tests\*
    d:\program\anaconda3\envs\cat\lib\site-packages\pylab.py
Proceed (Y/n)? y
  Successfully uninstalled matplotlib-3.5.3
(cat) PS E:\matlab> pip install matplotlib
Collecting matplotlib
  Using cached matplotlib-3.5.3-cp37-cp37m-win_amd64.whl (7.2 MB)
Requirement already satisfied: packaging>=20.0 in d:\program\anaconda3\envs\cat\lib\site-packages (from matplotlib) (21.3)
Requirement already satisfied: fonttools>=4.22.0 in d:\program\anaconda3\envs\cat\lib\site-packages (from 
matplotlib) (4.38.0)
Requirement already satisfied: numpy>=1.17 in d:\program\anaconda3\envs\cat\lib\site-packages (from matplotlib) (1.21.6)
Requirement already satisfied: cycler>=0.10 in d:\program\anaconda3\envs\cat\lib\site-packages (from matplotlib) (0.10.0)
Requirement already satisfied: kiwisolver>=1.0.1 in d:\program\anaconda3\envs\cat\lib\site-packages (from 
matplotlib) (1.3.1)
Requirement already satisfied: pillow>=6.2.0 in d:\program\anaconda3\envs\cat\lib\site-packages (from matplotlib) (8.2.0)
Requirement already satisfied: pyparsing>=2.2.1 in d:\program\anaconda3\envs\cat\lib\site-packages (from matplotlib) (2.4.7)
Collecting python-dateutil>=2.7
  Downloading python_dateutil-2.8.2-py2.py3-none-any.whl (247 kB)
     ---------------------------------------- 247.7/247.7 kB 633.2 kB/s eta 0:00:00
Requirement already satisfied: six in d:\program\anaconda3\envs\cat\lib\site-packages (from cycler>=0.10->matplotlib) (1.16.0)
Installing collected packages: python-dateutil, matplotlib
Successfully installed matplotlib-3.5.3 python-dateutil-2.8.2
(cat) PS E:\matlab>  e:; cd 'e:\matlab'; & 'D:\Program\Anaconda3\envs\cat\python.exe' 'c:\Users\asus\.vscode\extensions\ms-python.python-2022.20.2\pythonFiles\lib\python\debugpy\adapter/../..\debugpy\launcher' '14516' '--' 'e:\matlab\CHB-MIT-DATA\epilepsy_eeg_classification\preprocessing.py'

只是令我迷惑的是,安装matplotlib伴随安装的也是python-dateutil,而不是dateutil,但是偏偏bug没有了。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

ACMSunny

赠人玫瑰,手有余香。

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值