[Python]更新pip版本,更新pip源

您所在的位置:网站首页 python使用指定源pip [Python]更新pip版本,更新pip源

[Python]更新pip版本,更新pip源

2022-12-27 10:59| 来源: 网络整理| 查看: 265

更新pip版本:

D:PythonVirtualEnvPythonVirtualEnv_391Scriptspython.exe -m pip install --upgrade pip

使用指定源安装pip:

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

-i后的参数,为指定的源

常见的pip源:

pypi 清华大学源:https://pypi.tuna.tsinghua.edu.cn/simplepypi 豆瓣源 :http://pypi.douban.com/simple/pypi 腾讯源:http://mirrors.cloud.tencent.com/pypi/simplepypi 阿里源:https://mirrors.aliyun.com/pypi

上述做法是临时改成国内源,如果不想每次用 pip 都加上 -i https://pypi.tuna.tsinghua.edu.cn/simple,那么可以把国内源设为默认,做法是:

# 清华源 pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple # 或: # 阿里源 pip config set global.index-url https://mirrors.aliyun.com/pypi/simple/ # 腾讯源 pip config set global.index-url http://mirrors.cloud.tencent.com/pypi/simple # 豆瓣源 pip config set global.index-url http://pypi.douban.com/simple/

如何改回原来的源:pip config unset global.index-url

未验证:

这里有一点比较麻烦的地方,就是是 Linux 和 Windows 环境下的 pip 配置文件的名字和位置都不同,经常混淆。今天就教大家一招,快速搞定: 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://mirrors.aliyun.com/pypi/simple/ [install] trusted-host=mirrors.aliyun.com摘自:https://zhuanlan.zhihu.com/p/106697938


【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3