python模块管理 pip临时使用及永久镜像配置

pip安装依赖包速度很慢,此时您可能需要使用国内镜像来加速,特别是配置Home Assistant时,可能就是因为无法获取依赖包而配置失败。

pip临时使用镜像安装python依赖包

可以在使用pip的时候,加上参数-i和镜像地址,如果讨厌安全提示,添加 –trusted-host. 例如临时使用清华镜像安装python模块:

pip install -i https://pypi.tuna.tsinghua.edu.cn/simple pandas --trusted-host tuna.tsinghua.edu.cn

pip永久使用镜像安装python依赖包

首先查看当前用户是否有pip配置文件:

cat ~/.pip/pip.conf

Windows的pip配置文件位于:

%HOME%\pip\pip.ini

by ITGeeker

如果没有该文件,手动创建一个

mkdir -p ~/.pip
vi ~/.pip/pip.conf

如果想使用阿里云镜像,请添加:

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

注意:新版ubuntu要求使用https源

by ITGeeker

如果你有root权限,那么就全局更改吧:

echo -e "
[global]
index-url = https://mirrors.aliyun.com/pypi/simple
[install]
trusted-host = mirrors.aliyun.com
extra-index-url=https://www.piwheels.org/simple">/etc/pip.conf
cat /etc/pip.conf

国内常用pip镜像包括:

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

评论

《“python模块管理 pip临时使用及永久镜像配置”》 有 1 条评论

  1. […] 关于pip镜像配置,请参看:python模块管理 pip临时使用及永久镜像配置 […]

回复 树莓派Raspbian如何安装Home Assistant 非img刷卡安装 – ITGeeker技术奇客 取消回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据

奇客罗方公众号 奇客罗方小程序 奇客罗方客服 ITGeeker Telegram

网站由ITGeeker技术奇客开发并管理;隶属于GeekerCloud奇客罗方智能科技
Site designed and developed by ITGeekerwhich is a sub-website of GeekerCloud
网站地图 | 沪ICP备2021031434号-4