当前位置: 首页 > news >正文

【Python】pip安装加速:使用国内镜像源

【Python】pip安装加速:使用国内镜像源

零、使用命令行设置

设置全局镜像源

随便使用下面任一命令即可!

阿里云:

pip config set global.index-url https://mirrors.aliyun.com/pypi/simple/

豆瓣:

pip config set global.index-url https://pypi.douban.com/simple/

清华大学:

pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple/

中国科学技术大学:

pip config set global.index-url https://pypi.mirrors.ustc.edu.cn/simple/

遇到的问题,信任镜像源

最新版的pip要求必须使用https,如果源不是https协议的,会报如下错误:

WARNING: The repository located at … is not a trusted or secure host and is being ignored.

WARNING: The repository located at mirrors.aliyun.com is not a trusted or secure host and is being ignored. If this repository is available via HTTPS we recommen
d you use HTTPS instead, otherwise you may silence this warning and allow it anyway with '--trusted-host mirrors.aliyun.com'.
ERROR: Could not find a version that satisfies the requirement requests (from versions: none)
ERROR: No matching distribution found for requests                                           
WARNING: The repository located at mirrors.aliyun.com is not a trusted or secure host and is being ignored. If this repository is available via HTTPS we recommen
d you use HTTPS instead, otherwise you may silence this warning and allow it anyway with '--trusted-host mirrors.aliyun.com'.
WARNING: There was an error checking the latest version of pip.
解决方案一:切换为https的源(推荐)

一般在链接中把http替换成https即可,或者找对应的https源。

解决方案二:临时信任

可以在命令行后加上--trusted-host参数,例如:

pip install -i http://mirrors.aliyun.com/pypi/simple/ 依赖参数 --trusted-host mirrors.aliyun.com

壹、使用文件设置

Windows上按Windows+R键打开运行,输入%userprofile%打开个人文件夹,在个人文件夹中新建.pip目录,在目录中新建文本文档并改名为pip.conf,写入如下内容:

阿里云(http)

[global]
index-url = http://mirrors.aliyun.com/pypi/simple/
[install]
trusted-host=mirrors.aliyun.com

阿里云(https)

[global]
index-url = https://mirrors.aliyun.com/pypi/simple/

其他的源也是类似的,把链接改一下即可:

  • 豆瓣:https://pypi.douban.com/simple/
  • 清华大学:https://pypi.tuna.tsinghua.edu.cn/simple/
  • 中国科学技术大学:https://pypi.mirrors.ustc.edu.cn/simple/

叁、参考文档

  1. 国内pip源提示“not a trusted or secure host”解决方案
  2. pip源提示“not a trusted or secure host” 解决
  3. 【Python】已完美解决:WARNING: The repository located at mirrors .aliyun.com is not a trusted or secure host
  4. pip使用国内镜像源(附加全局修改)
http://www.lryc.cn/news/443066.html

相关文章:

  • SpringBoot lombok(注解@Getter @Setter)
  • descrTable常用方法
  • 回归预测 | Matlab实现ReliefF-XGBoost多变量回归预测
  • 年度最强悬疑美剧重磅回归,一集比一集上头
  • AI一点通: 简化大数据与深度学习工作流程, Apache Spark、PyTorch 和 Mosaic Streaming
  • Python知识点:深入理解Python的模块与包管理
  • 倒排索引(反向索引)
  • openCV的python频率域滤波
  • 探索视频美颜SDK与直播美颜工具的开发实践方案
  • Linux通过yum安装Docker
  • 面部表情数据集合集——需要的点进来
  • AI学习指南深度学习篇-Adagrad的Python实践
  • vue2使用npm引入依赖(例如axios),报错Module parse failed: Unexpected token解决方案
  • MySQl篇(基本介绍)(持续更新迭代)
  • Java开发与实现教学管理系统动态网站
  • 麒麟操作系统 MySQL 主从搭建
  • OSSEC搭建与环境配置Ubuntu
  • 【RabbitMQ】消息分发、事务
  • mysql mha高可用集群搭建
  • 如何解决“json schema validation error ”错误? -- HarmonyOS自学6
  • 基于Jeecg-boot开发系统--后端篇
  • Spring Boot实战:使用@Import进行业务模块自动化装配
  • Golang | Leetcode Golang题解之第415题字符串相加
  • 5. 数字证书与公钥基础设施
  • Centos中关闭swap分区,关闭内存交换
  • leetcode练习 二叉树的最大深度
  • Scrapy爬虫框架 Items 数据项
  • weblogic CVE-2018-2894 靶场攻略
  • 百易云资产管理运营系统 ticket.edit.php SQL注入漏洞复现
  • C++(2)进阶语法