如果你频繁使用Python的话,你对pip和Conda不太了解吧。 它们作为包管理器,为下载所需的Python包提供了极大的方便,但仅限于大多数人的Python包的服务器在国外。
由于国内下载速度较慢,需要配置镜像站提高下载速度。
一、pip 镜像站
1.pip 是什么
pip是一种通用的Python包管理器,具有搜索、下载、安装和卸载Python包的功能。
pip内置于Python3.4和2.7及更高版本中。 默认情况下,pip从PyPI下载软件包。 PyPI的全名是python package索引。
这是Python正式第三方( official third-party )软件包的软件存储库。
PyPI官方网站
2.镜像站列表
name | index-url | trusted-host |
阿里云 | https://mirrors.aliyun.com/pypi/simple/ | mirrors.aliyun.com |
豆瓣 | https://pypi.douban.com/simple/ | pypi.douban.com |
腾讯云 | https://mirrors.cloud.tencent.com/pypi/simple/ | mirrors.cloud.tencent.com |
华为云 | https://repo.huaweicloud.com/repository/pypi/simple/ | repo.huaweicloud.com |
清华大学 | https://pypi.tuna.tsinghua.edu.cn/simple/ | pypi.tuna.tsinghua.edu.cn |
北京外国语大学 | https://mirrors4.bfsu.edu.cn/pypi/web/simple/ | mirrors4.bfsu.edu.cn |
PyPI | https://pypi.org/ | pypi.org |
中科大的pip和Conda镜像站将被重定向到北京外国语大学镜像站,不列举
3.如何配置
显示pip安装源信息
每次使用pipconfiglist
.临时使用
pip安装软件包时,请指定镜像工作站
pip install [ package-name ]-I [ index-URL ]-- trusted-host [ trusted-host ]例如安装tensorflow时AlibabaCloud
pipinstalltensorflow-I https://mirrors.a liyun.com/pypi/simple//-- trusted-host mirrors.a liyun.com
.永久使用
pipconfigsetglobal.index-URL [ index-URL ] pipconfigsetinstall.trusted-host [ trusted-host ]例如,全局地alibababa clibaba
pipconfigsetglobal.index-URL https://mirrors.a liyun.com/pypi/simple/pipconfigsetinstall.trusted-host mirrors.all
[ global ] time out=600 index-URL=https://mirrors.a liyun.com/pypi/simple/extra-index-URL=https://pypi.douban.trusted-host=mirrors.a liyun.com pypi.douban.com pypi.org time out=600 :
.详细配置
Windows
Conda是一个开源软件包和环境管理系统,可以轻松安装多个版本的软件包及其依赖项,并在它们之间切换。 包管理与pip类似。
可用于管理Python的第三方软件包。
Conda官方网站
Linux/macOS
name | channels |
阿里云 | https://mirrors.aliyun.com/anaconda/ |
清华大学 | https://mirrors.tuna.tsinghua.edu.cn/anaconda/ |
北京外国语大学 | https://mirrors.bfsu.edu.cn/anaconda/ |
二、Conda 镜像站
Conda显示安装源信息
conda info
1.Conda 是什么
conda config--添加通道[ channels ]例如全球添加清华大学镜像站
conda config---- add channels https://mirrors.tuna.Tsinghua.edu.cn/anaconda/pkgs/main/conda config---add channels conda config-- add channels 3359 mirrors.tuna.Tsinghua.edu.cn/anaconda/pkgs/r/010 -
channels: - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/ - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/ - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r/ - https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/ - https://mirrors.bfsu.edu.cn/anaconda/pkgs/main/ - https://mirrors.bfsu.edu.cn/anaconda/pkgs/free/ - https://mirrors.bfsu.edu.cn/anaconda/pkgs/r/ - defaultsssl_verify: trueshow_channel_urls: trueauto_activate_base: false上述模板展示了Conda 主要库的镜像源,
ssl_verify: true:开启SSH 认证show_channel_urls: true:安装包时,
显示包的源地址auto_activate_base: false:关闭自动进入base 环境
2.镜像站列表
全局使用镜像站后,
会在用户根目录~ 中产生一个隐藏文件.condarc(~/.condarc)来记录配置信息(如果不存在就自己创建),具体内容和Windows 配置一样
来源:https://www.cnblogs.com/oranhext/p/py-mirrors.html
以上就是无忧自考网小编关于清华大学镜像站的全部内容,内容仅供参考,如果你还有其他疑问请访问无忧自考网高考专业频道