安装Matplotlib包时出现ReadTimeoutError,请求解决
解决Matplotlib安装超时问题
报错信息
WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ReadTimeoutError("HTTPSConnectionPool(host='files.pythonhosted.org', port=443): Read timed out. (read timeout=15)")': /packages/17/91/febbb6c1063ae05a62fdbe038c2917b348b1b35f0482cee4738e6870a44a/matplotlib-3.9.0-cp312-cp312-win_amd64.whl.metadata ERROR: Could not install packages due to an OSError: HTTPSConnectionPool(host='files.pythonhosted.org', port=443): Max retries exceeded with url: /packages/17/91/febbb6c1063ae05a62fdbe038c2917b348b1b35f0482cee4738e6870a44a/matplotlib-3.9.0-cp312-cp312-win_amd64.whl.metadata (Caused by ReadTimeoutError("HTTPSConnectionPool(host='files.pythonhosted.org', port=443): Read timed out. (read timeout=15)"))
解决方法
延长pip超时时间
执行安装命令时增加超时参数,给下载过程预留更长时间:pip install matplotlib --default-timeout=100使用国内PyPI镜像源
国内镜像服务器响应更快,能有效避免连接国外服务器超时,推荐使用以下镜像:# 清华镜像 pip install matplotlib -i https://pypi.tuna.tsinghua.edu.cn/simple # 阿里云镜像 pip install matplotlib -i https://mirrors.aliyun.com/pypi/simple/ # 同时结合超时参数 pip install matplotlib -i https://pypi.tuna.tsinghua.edu.cn/simple --default-timeout=100手动下载whl文件安装
- 找到匹配你Python版本和系统的whl文件(比如你需要的
matplotlib-3.9.0-cp312-cp312-win_amd64.whl) - 下载到本地后,执行本地安装命令:
pip install C:\path\to\matplotlib-3.9.0-cp312-cp312-win_amd64.whl注意替换路径为你实际的文件存储位置。
- 找到匹配你Python版本和系统的whl文件(比如你需要的
检查网络环境
暂时关闭代理工具、防火墙或杀毒软件,确保网络连接稳定后再尝试安装。
内容的提问来源于stack exchange,提问作者Mahdi Bd
相关产品推荐
相关产品推荐

