【折腾】Windows和Linux更换pip源

写在前面

python这东西毕竟也是国外开发的,因而肯定一如既往的需要更换源。这样下包的时候才会温柔尽丝滑!o( ̄︶ ̄)o

windows篇
  1. 直接 Win + R进入该目录下 (网路中有其他各种目录,不推荐)
    在这里插入图片描述
  2. 在该目录下创建pip目录并在pip目录下新建pip.ini (注意后缀哦,文本是带txt的要去掉!)
    在这里插入图片描述

在这里插入图片描述

  1. 文件内容为:
[global]
index-url = http://mirrors.aliyun.com/pypi/simple/
[install]
trusted-host = mirrors.aliyun.com
  1. 更新pip源python -m pip install --upgrade pip
  2. 开心使用

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

Linux篇

在用户目录下新建文件夹.pip,在文件夹内新建文件pip.conf,并在文件内填入以下内容

$ mkdir ~/.pip
$ vim ~/.pip/pip.conf
$ cat pip.conf
[global]
index-url=http://mirrors.aliyun.com/pypi/simple/
[install]
trusted-host=mirrors.aliyun.com

你可能会遇到一下警告
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 recommend you use HTTPS instead, otherwise you may silence this warning and allow it anyway with '--trusted-host mirrors.aliyun.com'.

你只需要注释掉[install]

[global]
index-url = http://mirrors.aliyun.com/pypi/simple/
#[install]
trusted-host = mirrors.aliyun.com

然后更新pip3 install --upgrade pip

剩下的跟windows使用方法一个样子

最后查看安装依赖版本 pip list

常用Windows系统变量
%ALLUSERSPROFILE%            C:\ProgramData
%APPDATA%                    C:\Users\用户名\AppData\Roaming
%COMMONPROGRAMFILES%         C:\Program Files\Common Files
%COMMONPROGRAMFILES(x86)%    C:\Program Files (x86)\Common Files
%COMSPEC%                    C:\Windows\System32\cmd.exe
%HOMEDRIVE%和%SystemDrive%   C:\
%HOMEPATH%                   C:\Users\用户名
%LOCALAPPDATA%               C:\Users\用户名\AppData\Local
%PROGRAMDATA%                C:\ProgramData
%PROGRAMFILES%               C:\Program Files
%PROGRAMFILES(X86)%          C:\Program Files (x86)
%PUBLIC%                     C:\UsersPublic
%SystemRoot%                 C:\Windows
%TEMP%和%TMP%                C:\Users\用户名\AppData\LocalTemp
%USERPROFILE%                C:\Users用户名
%WINDIR%                     C:\Window
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值