Kaggle 下载数据集报错:ModuleNotFoundError: No module named ‘urllib3’
一、报错:ModuleNotFoundError: No module named ‘urllib3’
报错内容如下:
Traceback (most recent call last):
File "/home/username/.local/bin/kaggle", line 5, in <module>
from kaggle.cli import main
File "/home/username/.local/lib/python3.8/site-packages/kaggle/__init__.py", line 19, in <module>
from kaggle.api.kaggle_api_extended import KaggleApi
File "/home/username/.local/lib/python3.8/site-packages/kaggle/api/__init__.py", line 22, in <module>
from kaggle.api.kaggle_api_extended import KaggleApi
File "/home/username/.local/lib/python3.8/site-packages/kaggle/api/kaggle_api_extended.py", line 46, in <module>
from ..api_client import ApiClient
File "/home/username/.local/lib/python3.8/site-packages/kaggle/api_client.py", line 42, in <module>
from kaggle.configuration import Configuration
File "/home/username/.local/lib/python3.8/site-packages/kaggle/configuration.py", line 36, in <module>
import urllib3
ModuleNotFoundError: No module named 'urllib3'
错误分析:根据报错内容提示,没有 ‘urllib3’ 这个包,但是环境中是有这个包的!于是,按照路径发现执行得是
/home/username/.local/lib/python3.8/site-packages/kaggle/
路径下的文件,既然是这个路径下的文件有问题,想着重新生成此目录即可。
二、解决方法
先删除
/home/username/.local/lib/
这个目录。
然后执行以下命令:
pip install --user kaggle
执行后发现已经成功生成
/home/username/.local/lib/
目录。然后再使用 Kaggle API 接口下载数据发现不报错。
成功解决!
版权声明:本文为qq_44743171原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。