关于python:Python-pip-设置国内源阿里源清华大学源

5次阅读

共计 1018 个字符,预计需要花费 3 分钟才能阅读完成。

背景

因为 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/

正文完
 0