Unable to import required dependencies: pytz: No module named ‘pytz‘ ,dateutil: No module named【已解决】
问题描述
执行程序时候报错如下:
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没有了。
更多推荐
所有评论(0)