Python pip 源设置成国内源,阿里云源,清华大学源,最方便的方式,都在这里了

文章目录

  • 背景
  • 代码替换
    • 设置阿里源(推荐这个)
    • 设置清华大学的
  • 手动替换
    • windows 替换
    • Mac 替换
  • 国内源列表(推荐用阿里云的)
  • 推荐阅读

背景

由于 python 自带的源下载速度非常慢,特别是安装一些库的时候,甚至有时会失败。

因此,建议将下载源替换成国内的,下载速度会快很多。总共有两种方法

  • 代码替换 (推荐使用这一种)
  • 手动替换

代码替换

设置阿里源(推荐这个)

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

pip config set install.trusted-host mirrors.aliyun.com

设置清华大学的

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

手动替换

windows 替换

首先在 windows 当前用户家的目录下,创建一个 pip 文件夹,然后创建一个pip.ini文件,修改文件内容为如下;

[global] 
index-url = http://mirrors.aliyun.com/pypi/simple/ 
[install] 
trusted-host=mirrors.aliyun.com 
  1. 记得一定是pip.ini,如果没有开后缀的同学,记得把文件后缀打开,再修改文件的后缀为ini即可。
  2. 用户家目录为
C:Users****   # **** 就是当前登录用户名, 比如登录用户名是Luke, 那么就是C:/Users/junxu  

Mac 替换

会在目录下自动生成,不同系统,目录可能不同,所以使用命令行最靠谱
~/.config/pip/pip.conf

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

[install]
trusted-host = mirrors.aliyun.com

国内源列表(推荐用阿里云的)

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

推荐阅读

2023年创新创意 SpringBoot+Vue 毕业设计选题推荐,200 套 SptingBoot 精品项目,总有你需要的。

200 套 Java 精品项目

Python 200 套 精品项目

文章出处登录后可见!

已经登录?立即刷新

共计人评分,平均

到目前为止还没有投票!成为第一位评论此文章。

(0)
心中带点小风骚的头像心中带点小风骚普通用户
上一篇 2023年5月26日
下一篇 2023年5月26日

相关推荐