当前位置: 代码网 > it编程>前端脚本>Python > Python Anaconda以及Pip配置清华镜像源代码示例

Python Anaconda以及Pip配置清华镜像源代码示例

2024年05月18日 Python 我要评论
前言提示:最近换了新电脑,在使用anaconda安装python包时,系统会自动从默认源下载安装包,但是由于网络访问限制或网络连接速度较慢等原因,会导致安装失败或安装速度较慢。因此,为了提高安装速度和

前言

提示:

最近换了新电脑,在使用anaconda安装python包时,系统会自动从默认源下载安装包,但是由于网络访问限制或网络连接速度较慢等原因,会导致安装失败或安装速度较慢。

因此,为了提高安装速度和稳定性,一些用户选择使用国内的镜像源,如清华镜像源。配置清华镜像源可以让用户从国内的服务器上下载python包,这可以加快下载速度,并减少由于网络访问限制导致的下载失败等问题。

一、conda配置清华镜像源

1. 查看镜像源

conda config --show channels

2. 删除添加源,恢复默认源

conda config --remove-key channels

3. 添加清华镜像源

#添加镜像源
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/pro
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/msys2

#终端显示包从哪个channel下载,以及下载地址是什么
conda config --set show_channel_urls yes

二、pip配置清华镜像源

1. 临时使用清华镜像源

代码如下(示例):

# some-package代表你需要安装的包
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple some-package

下面这种方式也是一样的

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

2.永久配置

代码如下(示例):

pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple

三、国内常用的镜像源

pip install -i https://mirrors.aliyun.com/pypi/simple/ some-package

清华大学开源软件镜像站:https://pypi.tuna.tsinghua.edu.cn/simple
阿里云开源镜像站:https://mirrors.aliyun.com/pypi/simple/
豆瓣:https://pypi.douban.com/simple/
中国科技大学 https://pypi.mirrors.ustc.edu.cn/simple/

上海交通大学开源镜像站

conda config --add channels https://mirrors.sjtug.sjtu.edu.cn/anaconda/pkgs/main/
conda config --add channels https://mirrors.sjtug.sjtu.edu.cn/anaconda/pkgs/free/
conda config --add channels https://mirrors.sjtug.sjtu.edu.cn/anaconda/cloud/conda-forge/

中国科学技术大学

conda config --add channels https://mirrors.ustc.edu.cn/anaconda/pkgs/main/
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/pkgs/free/
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/cloud/conda-forge/

华中理工大学:

conda config --add channels http://pypi.hustunique.com/

山东理工大学:

conda config --add channels http://pypi.sdutlinux.org/ 

总结

到此这篇关于python anaconda以及pip配置清华镜像源的文章就介绍到这了,更多相关anaconda及pip配置清华镜像源内容请搜索代码网以前的文章或继续浏览下面的相关文章希望大家以后多多支持代码网!

(0)

相关文章:

版权声明:本文内容由互联网用户贡献,该文观点仅代表作者本人。本站仅提供信息存储服务,不拥有所有权,不承担相关法律责任。 如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至 2386932994@qq.com 举报,一经查实将立刻删除。

发表评论

验证码:
Copyright © 2017-2025  代码网 保留所有权利. 粤ICP备2024248653号
站长QQ:2386932994 | 联系邮箱:2386932994@qq.com