pip默认源存在速度慢的问题,本文介绍pip命令添加国内源的方法。
pip install Package
pip install -r requirements.txt
pip install -U Package
pip uninstall Package
pip list
pip freeze
pip freeze -r requirements.txt
pip show -f Package
新版ubuntu要求使用https源,要注意
在使用pip的时候,加上参数
-i
和镜像地址
pip install -i https://mirrors.aliyun.com/pypi/simple/ tensorboard
从清华源安装 tensorboard
在终端输入命令:
pip install pip -U # 升级pip到最新版本
pip config set global.index-url https://mirrors.aliyun.com/pypi/simple/
此方法配置后安装包时可能会提示下载源不可信,需要手动加上
--trusted-host mirrors.aliyun.com
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'.
这样就不那么香了,一劳永逸的解决方案是修改pip配置文件
配置文件位置:
~/.pip/pip.conf
~/.config/pip/pip.conf
[global]
index-url = https://mirrors.aliyun.com/pypi/simple/
trusted-host = mirrors.aliyun.com
配置文件位置:
%HOMEPATH%\pip\pip.ini
,即 C:\Users\pip\pip.ini
%APPDATA%\pip\pip.ini
,即C:\Users\AppData\Roaming\pip\pip.ini
可以通过在cmd中输入
echo %APPDATA%
或echo %HOMEPATH%
查看自己的相关路径
[global]
index-url = https://mirrors.aliyun.com/pypi/simple/
[install]
trusted-host = mirrors.aliyun.com
http
不可信,将源地址修改为 https
也可以避免信任危机[global]
index-url = https://mirrors.aliyun.com/pypi/simple/
扫码关注腾讯云开发者
领取腾讯云代金券
Copyright © 2013 - 2025 Tencent Cloud. All Rights Reserved. 腾讯云 版权所有
深圳市腾讯计算机系统有限公司 ICP备案/许可证号:粤B2-20090059 深公网安备号 44030502008569
腾讯云计算(北京)有限责任公司 京ICP证150476号 | 京ICP备11018762号 | 京公网安备号11010802020287
Copyright © 2013 - 2025 Tencent Cloud.
All Rights Reserved. 腾讯云 版权所有