【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/

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

叁、参考文档

  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使用国内镜像源(附加全局修改)

【Python】pip安装加速:使用国内镜像源的更多相关文章

  1. pip安装模块使用国内镜像源加速安装

    今天在安装Python模块matplotlib的时候,一直安装不成功,老是提示“socket.timeout: The read operation timed out”或者“Read timed o ...

  2. pip安装超时,更换国内镜像源安装

    pip安装超时问题 pip install --index 源地址 安装包 常用镜像源地址: http://pypi.douban.com/ 豆瓣 http://pypi.mirrors.ustc.e ...

  3. Python中使用pip安装库时指定镜像源为豆瓣镜像源

    场景 在使用pip进行安装库时,使用默认的库会很慢,甚至有时会出现远程主机中断了一个现有连接. 怎样在使用pip install 时指定镜像源为豆瓣镜像源. 实现 pip install moviep ...

  4. pip 安装包 使用国内镜像源

    1.pipy国内镜像目前有: 阿里云  http://mirrors.aliyun.com/pypi/simple/  中国科技大学  https://pypi.mirrors.ustc.edu.cn ...

  5. 修改apt,pip,npm为国内镜像源

    apt 原文件备份 sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak 编辑源列表文件 sudo vim /etc/apt/sources. ...

  6. 如何将python下载源地址修改为国内镜像源

    (1)在  C:\Users\xxx 下面创建新的目录  pip 文件夹 (2)在 pip目录下创建后缀为ini,名为pip的文件,另存为  (pip.ini) 文件内容设置为:(清华源) [glob ...

  7. python中pip添加国内镜像源后显著加速下载

    python中pip添加国内镜像源后显著加速下载 更换pip源到国内镜像,很多国外的库下载非常慢,添加国内镜像后安装下载速度提升非常明显(亲测有些可以由几十kb加速到几MB) pip国内的一些镜像阿里 ...

  8. python pip 安装常用库如何使用国内镜像源

    最近通过python安装一些常用库发现下载速度特别慢,而且还会出现无法安装等错误,尝试找了一些国内的镜像源,发现阿里云的速度很快,这里做个记录,并分享给大家. 国内镜像源 阿里云:http://mir ...

  9. python pip 安装使用国内镜像源

    国内镜像源 清华:https://pypi.tuna.tsinghua.edu.cn/simple 阿里云:http://mirrors.aliyun.com/pypi/simple/ 中国科技大学 ...

  10. Ubuntu16.04下配置pip国内镜像源加速安装【转】

    本文转载自:https://blog.csdn.net/yucicheung/article/details/79095742 问题描述 基于国内网速的问题,我们直接pip安装包通常速度非常慢,而且经 ...

随机推荐

  1. 查看Android是否开机启动进入桌面

    adb 或者 串口终端 getprop sys.boot_completed 返回空代表没有进入桌面返回1代表已进入桌面

  2. 基于.NET8.0实现RabbbitMQ的Publish/Subscribe发布订阅以及死信队列

    [前言] RabbitMQ提供了五种消息模型,分别是简单模型.工作队列模型.发布/订阅模型.路由模型和主题模型.‌‌ 简单模型(Simple)‌:在这种模式下,一个生产者将消息发送到一个队列,只有一个 ...

  3. CDS标准视图:会计员 I_AccountingClerk

    视图名称:会计员 I_AccountingClerk 视图类型:基础 视图代码: 点击查看代码 @AbapCatalog: { sqlViewName: 'IFIACCCLERK', // compi ...

  4. Superset 用户集成方案

    注意,一下内容来自外网浏览器翻译,本人使用了将superset集成进入第三方系统,superset采用自定义身份验证+第三系统iframe嵌入方式,但是这个方式存在一个问题,iframe与redire ...

  5. win10 linux子系统的一些想法

    什么是linux子系统 具体的概念网上很多,作为个技术人简单粗暴来说就是微软脑子瓦特,突然爱上了linux, 可以在win10安装linux子系统 子系统不同于虚拟机,但是其优点是安装很快,对于新手和 ...

  6. linux shell 脚本调试技巧

    本文分享自天翼云开发者社区<linux shell 脚本调试技巧>,作者:g****n 1.bash -x 加脚本 这是最常用的调试手段,终端会打印出,脚本执行过程中的每一个命令. a. ...

  7. centos7关闭不必要的服务和端口

    云服务器开启很多不必要的端口,造成安全隐患 TCP 25端口:邮件服务 systemctl stop postfix 53端口 :域名解析服务 systemctl stop rhel-domainna ...

  8. kubernets学习笔记二

    Kubernetes部署"容器化应用" Kubernetes整体架构 何为"容器化应用"? 通俗点来说,就是你把一个程序放在docker里部署,这个docker ...

  9. IDEA引入大项目一直updating indices解决办法

    一.如项目不需要某个目录建立索引 右键需要排除的项目

  10. Luogu P9055 [集训队互测 2021] 数列重排 题解 [ 紫 ] [ 构造 ] [ 数学 ]

    数列重排:差点就场切的神仙构造,最后一步想假了,导致我模拟赛荣获 25+5+0 的好成绩! 这题部分分很有启发性,跟着一步一步打基本能想到正解的构造,但也有可能想偏部分分的意思,想假策略. 构造 先看 ...