栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Python

pip 指定源安装

Python 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

pip 指定源安装

临时更换
pip安装库的时候指定 -i +源

一些常用源
阿里云 http://mirrors.aliyun.com/pypi/simple/
腾讯 https://mirrors.tencent.com/pypi/simple/
中国科技大学 https://pypi.mirrors.ustc.edu.cn/simple/
豆瓣 http://pypi.douban.com/simple/
清华大学 https://pypi.tuna.tsinghua.edu.cn/simple/
中国科学技术大学 http://pypi.mirrors.ustc.edu.cn/simple/

例如
pip install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple/
永久更换 一行命令搞定的做法
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple

提示 ERROR: unknown command “config“的话 升级pip即可

取消全局设置
pip config unset global.index-url
创建文件的做法

Linux/Mac os 环境中

修改pip的配置文件 ~/.pip/pip.conf: 如果没有这个文件的话,直接新建一个就好了。里面配置一个值:

[global]
timeout = 60
index-url = http://pypi.douban.com/simple
[install]
trusted-host = https://pypi.tuna.tsinghua.edu.cn

timeout设置安装包时的超时时长
index-url就是配置指定的源了
配置好后,下次通过pip安装时就会默认通过配置文件里指定的源去下载安装包了

Windows下,你需要在当前对用户目录下(C:Usersxxpip,xx 表示当前使用对用户)创建一个 pip.ini在pip.ini文件中输入以下内容:

[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
[install]
trusted-host = pypi.tuna.tsinghua.edu.cn

查看 镜像地址:
pip config list

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/938293.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号