python2 & python3共存,pip国内源

一、python2和python3的安装

Python2 和Python3安装过程大体一样【不会自行百度】。
正常安装即可,【不会配环境变量勾选上】,安装时自动增加环境变量。
在这里插入图片描述

1.配置参数

Python2的目录结构不用动,只需要修改Python3 安装目录即可,如图所示
在这里插入图片描述

2.验证Python是否配置成功

python -V
python3 -V

在这里插入图片描述

3.安装pip

python -m pip install --upgrade pip --force-reinstall
python3 -m pip install --upgrade pip --force-reinstall

在这里插入图片描述
至此配置完成

二、配置国内源

临时修改

pip install xxxx -i https://pypi.tuna.tsinghua.edu.cn/simple 

永久修改

  1. win+r 输入%APPDATA%
  2. 按回车跳转到以下目录,新建pip文件夹
  3. 创建pip.ini文件
  4. 打开文件夹,输入以下内容,关闭即可(注意:源镜像可替换)
[global]
index-url = https://mirrors.aliyun.com/pypi/simple/
[install]
trusted-host = mirrors.aliyun.com

第二种方式永久修改

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

验证镜像源配置

pip config list 	#该命令的含义是查看已经拥有了哪些配置

在这里插入图片描述

其他国内源

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

至此所有配置完成

三、其他

pip config list -v		#列出尝试获取的配置文件名完整路径列出来了

在这里插入图片描述

  • global - 全局,一般不用
  • user - 当前用户,推荐
  • site - 只针对某一个 python 解释器

可以看到 user 有两个地方,其中配置任何一个都是可以的。

编辑配置

在命令行直接执行 pip config edit 会自动为我们打开配置文件。但是在 Windows 环境下还不行【需要手动指定编辑器,记事本就ok】,如下:

pip config edit  --editor notepad

注意:如果你从来没有设置过,它会报 找不到指定路径,这是因为相应的文件夹没有创建。

pip config set 		#直接设置配置项
ERROR: Got unexpected number of arguments, expected 2. (example: "pip config set [name] [value]")

示例:

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

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

如有错误,请留言~

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值