python2和python3共存 pip国内源
python2和python3的安装
1.安装py2和py3
安装的步骤基本一样,这里以py2为例
选择安装的用户
选择安装目录
注意,这里要选择配置环境变量
结束安装
2.配置参数
python2的目录不需要动
python3的目录修改为下图
3.安装pip
python -m pip install --upgrade pip --force-reinstall
python3 -m pip install --upgrade pip --force-reinstall
输入验证安装
pip -V
pip3 -V
pip更换国内源
1.win+r 输入%APPDATA%
2.按回车跳转到以下目录,新建pip文件夹
3.创建pip.ini文件
4.打开文件夹,输入以下内容,关闭即可(注意:源镜像可替换)
[global]
timeout = 6000
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
trusted-host = pypi.tuna.tsinghua.edu.cn
阿里云: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/
5.如果pip版本>=10.0.0,则可使用以下pip config set global.index-url命令进行配置
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
6.如果仅是临时使用国内源,则可使用pip install -i命令指定当前安装所使用的镜像源即可
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple numpy