惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

T
The Exploit Database - CXSecurity.com
A
Arctic Wolf
K
Kaspersky official blog
T
Threat Research - Cisco Blogs
PCI Perspectives
PCI Perspectives
www.infosecurity-magazine.com
www.infosecurity-magazine.com
P
Privacy International News Feed
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
U
Unit 42
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Simon Willison's Weblog
Simon Willison's Weblog
P
Privacy & Cybersecurity Law Blog
O
OpenAI News
量子位
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
C
Cisco Blogs
AWS News Blog
AWS News Blog
Vercel News
Vercel News
Microsoft Security Blog
Microsoft Security Blog
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
美团技术团队
T
Threatpost
S
Schneier on Security
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
C
Cyber Attacks, Cyber Crime and Cyber Security
Last Week in AI
Last Week in AI
C
CERT Recently Published Vulnerability Notes
Blog — PlanetScale
Blog — PlanetScale
C
Cybersecurity and Infrastructure Security Agency CISA
F
Full Disclosure
博客园_首页
N
Netflix TechBlog - Medium
Security Latest
Security Latest
有赞技术团队
有赞技术团队
Google DeepMind News
Google DeepMind News
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
The Register - Security
The Register - Security
Application and Cybersecurity Blog
Application and Cybersecurity Blog
Recent Announcements
Recent Announcements
博客园 - Franky
P
Palo Alto Networks Blog
Project Zero
Project Zero
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
H
Help Net Security
Hacker News: Ask HN
Hacker News: Ask HN
Cisco Talos Blog
Cisco Talos Blog
H
Heimdal Security Blog
The Hacker News
The Hacker News
博客园 - 【当耐特】
GbyAI
GbyAI

菜鸟教程

Linux Cron 定时任务 | 菜鸟教程 REST API 教程 | 菜鸟教程 Python 进度条 | 菜鸟教程 ChromeDriver 说明 | 菜鸟教程 Trae 入门教程 | 菜鸟教程 Dify 零门槛打造专属 AI 应用 | 菜鸟教程 1.11 算法代码练习 | 菜鸟教程 解决 VS 编译中产生 C4996 错误的方式 中国大模型大全 | 菜鸟教程
pip 指定国内镜像,并设置不使用 https | 菜鸟教程
tianqixin · 2025-03-07 · via 菜鸟教程

使用 pip 安装包,有时候会出现以下问题:

Could not fetch URL https://pypi.org/simple/pip/:  There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/pip/ (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1018)'))) - skipping

这个错误信息表明在尝试访问 https://pypi.org/simple/pip/ 时,遇到了 SSL 证书验证失败的问题。

具体来说,错误信息中提到的 SSLCertVerificationError 表示客户端无法验证服务器的 SSL 证书。

解决方法也很简单,我们可以使用国内镜像,比如清华的 pip 镜像。

方法 1:命令行临时指定

在安装 Python 包时,可以通过 --index-url 参数指定清华大学的镜像源,并通过 --trusted-host 参数允许不使用 HTTPS。

命令如下:

pip install <package_name> --index-url http://pypi.tuna.tsinghua.edu.cn/simple --trusted-host pypi.tuna.tsinghua.edu.cn
  • --index-url:指定镜像源的 URL。
  • --trusted-host:指定信任的主机,允许不使用 HTTPS。

例如:

pip install baidusearch --index-url http://pypi.tuna.tsinghua.edu.cn/simple --trusted-host pypi.tuna.tsinghua.edu.cn

方法 2:全局配置

如果你希望永久设置清华大学的镜像源,并且不使用 HTTPS,可以通过修改 pip 的配置文件来实现。

配置文件路径:

  • Windows:%APPDATA%\pip\pip.ini
  • macOS/Linux:~/.config/pip/pip.conf

在配置文件中添加以下内容:

[global]
index-url = http://pypi.tuna.tsinghua.edu.cn/simple
trusted-host = pypi.tuna.tsinghua.edu.cn

这样,每次使用 pip 时都会自动使用清华大学的镜像源,并且不会强制使用 HTTPS。