2022年Anaconda配置 pip 国内镜像源

项目场景:

有时候安装一些依赖包,网速慢,直接超时,可以指定国内源镜像。

pip install -i 国内镜像地址 包名
或者 python -m pip install -i 国内镜像地址 包名
也可以在 pip的时候控制超时, 具体参数为“–default-timeout=100”,
例如:

pip install -i https://mirrors.aliyun.com/pypi/simple/ numpy
python -m pip install  -i https://mirrors.aliyun.com/pypi/simple/ numpy
python -m pip --default-timeout=100 install -i https://mirrors.aliyun.com/pypi/simple/ numpy

国内常用源镜像地址:

清华:https://pypi.tuna.tsinghua.edu.cn/simple

阿里云:https://mirrors.aliyun.com/pypi/simple/

中国科技大学 https://pypi.mirrors.ustc.edu.cn/simple/

华中理工大学:http://pypi.hustunique.com/

山东理工大学:http://pypi.sdutlinux.org/ 

豆瓣:https://pypi.douban.com/simple/

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

生成: pip freeze > requirements.txt 
导入: pip install -r requirements.txt

出现Looking in indexes: http://pypi.douban.com/simple/:

Remainder of file ignored
Looking in indexes: http://pypi.douban.com/simple/
WARNING: The repository located at pypi.douban.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 pypi.douban.com'.
ERROR: Could not find a version that satisfies the requirement setuptools (from versions: none)
ERROR: No matching distribution found for setuptools

添加trusted-host 选项,否则使用的时候会提示不受信任

例如:

pip install -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com '模块版本'

1、修改源方法(永久修改)
linux:
修改 ~/.pip/pip.conf (没有就创建一个), 内容如下:

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

查看 镜像地址:

pip3 config list 

windows:
直接在user目录中创建一个pip目录,如:C:\Users\xx\pip,新建文件pip.ini,

windows在%HOMEPATH%\pip\pip.ini

内容如下:

[global]
index-url = http://pypi.douban.com/simple
[install]
trusted-host=pypi.douban.com

配置国内镜像源方法

1、显示镜像源

conda config --show channels

如图,我的是默认设置

在这里插入图片描述
2、添加新镜像源

conda config --add channels [urls…]

如图所示,添加成功
在这里插入图片描述
3、删除镜像源

conda config --remove-key channels 删除所有的镜像源,恢复到默认
conda config --remove channels [urls] 删除指定的镜像源

如图所示,删除成功

在这里插入图片描述
4、设置搜索时显示通道地址

conda config --set show_channels_urls yes

5、conda 安装指定的源

conda install -c [urls] [lib_name] # 这两个参数自定义
  • 2
    点赞
  • 31
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

落花雨12138

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值