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

永久设置pip指定国内镜像源(windows内)

1.首先列出国内四个镜像源网站:
一、清华源 https://pypi.tuna.tsinghua.edu.cn/simple/
二、阿里源 https://mirrors.aliyun.com/pypi/simple
三、中科大源 https://pypi.mirrors.ustc.edu.cn/simple/
四、豆瓣源 http://pypi.douban.com/simple/
2.一般下载所需要的python库包使用以下命令:

#手动使用清华源
pip install xxx -i https://pypi.tuna.tsinghua.edu.cn/simple/
#手动使用阿里源
pip install xxx -i https://mirrors.aliyun.com/pypi/simple
#手动使用中科大源
pip install xxx -i https://pypi.mirrors.ustc.edu.cn/simple/
#手动使用豆瓣源
pip install xxx -i http://pypi.douban.com/simple/

3.我们的问题来了,有时候手动去使用命令下载python库包时,手动去使用国内pip源复制一下没问题,但是下载python库包多了时总是需要去复制网址就会觉得很烦躁,下面我们就来说一说如何永久配置pip源(Windows内),以清华源为例。
(1)新建一个文件夹叫pip
在这里插入图片描述
(2)进入pip文件夹内,新建一个txt文件叫pip.txt
在这里插入图片描述
(3)使用记事本打开pip.txt
在这里插入图片描述
(4)输入pip清华源的配置代码

[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
[install]
use-mirrors =true
mirrors =https://pypi.tuna.tsinghua.edu.cn/simple
trusted-host =pypi.tuna.tsinghua.edu.cn

在这里插入图片描述
(5)保存pip.txt文件并且将pip.txt文件名后缀修改成pip.ini
在这里插入图片描述
(6)将包含pip.ini文件的pip文件夹放入路径C:\Users\Administrator中(注意:其中Administrator名字不是唯一,根据自己的名字路径来)
在这里插入图片描述
(7)复制粘贴成功后,准备下载一个python库包进行测试,按住Windows+R键,输入cmd打开命令窗口,输入:

pip install pyyaml

在这里插入图片描述
4.最后出现Looking in indexes: https://mirrors.aliyun.com/pypi/simple标志着使用国内清华源镜像成功,想要使用其他镜像的可以根据网址修改代码部分,有3处需要修改,修改的位置如下
在这里插入图片描述
5.换成阿里源代码如下

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

6.换成中科大源代码如下

[global]
index-url = https://pypi.mirrors.ustc.edu.cn/simple/
[install]
use-mirrors =true
mirrors = https://pypi.mirrors.ustc.edu.cn/simple/
trusted-host = pypi.mirrors.ustc.edu.cn

7.换成豆瓣源代码如下

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

8.总结,有时候pip源不稳定就需要换其他的源,比如现在2023年8月21号,豆瓣源用不了了,因为它的网站好像有问题,下载库包一直卡在那里不动半个多小时,只能换源解决了。大家觉得写的不错的,记得给我一键三连哦!

http://www.lryc.cn/news/133482.html

相关文章:

  • 【SA8295P 源码分析】27 - QNX Ethernet MAC 驱动 之 emac_tx_thread_handler 数据发送线程 源码分析
  • 爬虫抓取数据时显示超时,是代理IP质量不行?
  • 【管理运筹学】第 5 章 | 整数规划 (2,割平面法及 0-1 变量的特性)
  • Vscode详细安装教程
  • 法线矩阵推导
  • 对容器、虚拟机和 Docker 的初学者友好介绍
  • linux部署clickhouse(单机)
  • vue组件注册
  • day20 飞机大战射击游戏
  • iOS设计规范是什么?都有哪些具体规范
  • 动手学深度学习-pytorch版本(二):线性神经网络
  • Spark 图计算ONEID 进阶版
  • Comparable和Comparator区别
  • JAVA知识点梳理
  • [SWPUCTF 2022 新生赛]ez_ez_php
  • GraphQL strawberry的使用回顾和体会
  • 08无监督学习——聚类
  • Python使用OpenCV库对彩色图像进行通道分离
  • 前端面试:【CSS】盒模型、选择器、布局、响应式设计、Flexbox 与 Grid
  • 深入浅出通过PHP封装根据商品ID获取抖音商品详情数据方法
  • 排序(七种排序)
  • 【工程优化问题】基于鲸鱼、萤火虫、灰狼优化算法的张力、压缩弹簧设计问题研究(Matlab代码实现)
  • sap ui5刷新页面的方式
  • Java课题笔记~ Fastjson 概述
  • Arduino 入门学习笔记11 读写内置EEPROM
  • 【Nginx】安装make后遇到/bin/sh: 第 0 行:cd: ../pcre-8.38: 没有那个文件或目录
  • 在Windows Server 2008上启用自动文件夹备份
  • 数据结构—线性表的查找
  • EndNote(一)【界面+功能介绍】
  • JWT令牌验证