首页 > 编程语言 >【Python】pip安装加速:使用国内镜像源

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

时间:2024-09-21 22:25:51浏览次数:1  
标签:aliyun mirrors Python host https pip 镜像 com

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

标签:aliyun,mirrors,Python,host,https,pip,镜像,com
From: https://www.cnblogs.com/minuhy/p/18424608

相关文章

  • node镜像制作使用
    jenkins打包,直接使用nginx镜像/node镜像1.1piplinepipeline{agentanyoptions{timestamps()}environment{CRET_ID='7a52'IMAGE_NAME="harbor.xxx.xxx/xxx-pip/{JOB_NAME}-{PROJECT_ENV}"NAMESPACES='java-{PROJECT_ENV}&......
  • 新鲜的Win11/10镜像,全系列下载!
    Windows每个月都来一次例行更新,大吉大利今晚装机!2024年9月份ISO镜像,来咯~我们不生产系统,我们只是大自然微软的搬运工本文提供Windows11、Windows10、WindowsServer2022、Server23H2包含简体中文/繁体中文/英文语言,总共22个ISO镜像。微软对不同版本提供的生命周期有所区......
  • node.js安装与npm镜像源切换
    下载nvm点击进入nvmgit仓库下载nvmwindows用户点击exe文件进行下载。下载完毕之后点击安装包进行安装检查是否安装成功打开windows控制栏输入nvm-v检查是否安装成功使用nvm下载node.js打开控制栏输入nvminstalllatest安装当前node......
  • 【Python爬虫系列】_022.异步文件操作aiofiles
    课程推荐我的个人主页:......
  • 2023年Python计算机二级学习资料分享下载(小黑课堂)
    今天不学习,明天变垃圾。各位长方体移动工程师大家好!小白有一份珍贵的Python计算机二级学习资料分享给大家,正所谓“少壮不努力,长大去工地”,只有学习才能出人头地。资料内容如下:真题讲解内容:直播讲解内容:课程必看内容:为了让大家沉迷学习无法自拔,我们免费提供宝贵的学习资源,需要注意的......
  • python有main函数吗
    python和C++/Java不一样,没有主函数一说,也就是说python语句执行不是从所谓的主函数main开始的。当运行单个python文件时,如运行a.py,这个时候a的一个属性__name__是__main__。当调用某个python文件时,如b.py调用a.py,这个时候a的属性__name__是模块名a。a = 3 def chan......
  • python怎么初始化数组
    因为画图中x轴与y轴的数据通常为数组格式的数据,所以先总结一下如何初始化数组:(1)list得到数组# 通过array函数传递list对象L = [1, 2, 3, 4, 5, 6]a = np.array(L)# 若传递的是多层嵌套的list,将创建多维数组b = np.array([[1, 2, 3, 4], [5, 6, 7, ......
  • Python文件操作
    文件的编码编码就是一种规则集合,记录了内容和二进制间进行相互转换的规则,编码有许多种,我们最常用的是UTF-8编码常见的编码方式UTF-8:叫万国码-8bit是当前最流行的Unicode编码方式的字符集GBK:GBK向下与GB2312编码兼容,主要用于中文扩展为什么需要使用编码:计算机只......
  • python基频曲线
    在Python中,可以使用matplotlib库来绘制基频曲线(即音乐的音调曲线)。以下是一个简单的例子,演示如何绘制一个简单的正弦波基频曲线:importnumpyasnpimportmatplotlib.pyplotasplt#参数A=1.0#振幅f=440.0#频率(Hz),人耳听力的基准频率......
  • Python——列表与函数的关系
    目录1.问题描述2.与Python其他序列类型比较3.与C语言比较4.结论1.问题描述Python中为方便对列表进行修改,规定列表传入函数后进行的修改是直接针对原列表所在地址的,即在函数中对传入的列表的修改是全局的、永久的。示例代码如下:deffun(list):list[0][0]=18lis......