使用 清华大学开源软件镜像站 加速pip/conda/ubuntu/ros下载

1.什么是清华大学开源软件镜像站

清华大学开源软件镜像站,简称清华大学镜像站或清华镜像站或清华源,是一个位于中国清华大学的服务器,提供了大量开源软件的下载服务。这个镜像站的主要目的是为了提高国内用户访问和下载开源软件的速度和稳定性。由于国际网络连接可能受限或较慢,国内用户直接从国外服务器下载软件可能会遇到困难。清华大学镜像站通过在国内复制(即“镜像”)这些软件,使得国内用户可以更快速、更可靠地下载它们。

这个镜像站支持多种开源软件和系统的镜像,包括但不限于各种Linux发行版(如Ubuntu、Fedora等)、各种编程语言的包管理器(如Python的Pip、Node.js的Npm等)以及其他流行的开源项目。它是国内最大和最受欢迎的开源软件镜像站之一,为中国的开源社区做出了巨大的贡献。

2.为什么要使用镜像站下载

加速下载:镜像站通常设在不同地区,用户可以选择离自己最近的服务器进行下载,从而获得更快的下载速度。

减轻主服务器负担:通过多个镜像分散流量,减少对主服务器的压力,保证服务的稳定性和可靠性。

提高可用性:如果主服务器出现问题,用户仍然可以通过镜像站获取所需的文件。

满足特定地区需求:有些镜像站可能针对特定地区的用户提供特别优化的服务,比如本地化的内容。

避免网络限制:在某些情况下,主服务器可能因为地理位置或政策原因无法访问,镜像站可以提供替代的下载途径。

PyPI

什么是pypi

The Python Package Index (PyPI) is a repository of software for the Python programming language.
Python 包索引 (PyPI) 是 Python 编程语言的软件存储库。

pypi官网

https://pypi.org/

PyPI 镜像使用帮助

PS: 完整的镜像使用帮助信息可在 https://mirrors.tuna.tsinghua.edu.cn/help/pypi/ 找到

PyPI 镜像在每次同步成功后间隔 5 分钟同步一次。

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

注意,simple 不能少, 是 https 而不是 http

eg:

  1. 安装cv2
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple opencv-python
  1. 安装tqdm
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple tqdm
  1. 安装cv2 & 安装tqdm
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple opencv-python tqdm
设为默认

ps:建议使用该方法

升级 pip 到最新的版本 (>=10.0.0) 后进行配置:

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

如果您到 pip 默认源的网络连接较差,临时使用本镜像站来升级 pip:

python -m pip install -i https://pypi.tuna.tsinghua.edu.cn/simple --upgrade pip

设为默认后 以后都可使用正常的 pip install some-package 来安装需要的包了

eg:

pip install opencv-python tqdm

Anaconda 镜像使用帮助

Anaconda 是一个用于科学计算的 Python 发行版,支持 Linux, Mac, Windows, 包含了众多流行的科学计算、数据分析的 Python 包。

Anaconda 安装包可以到 https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/ 下载。

TUNA 还提供了 Anaconda 仓库与第三方源(conda-forge、msys2、pytorch等,查看完整列表,更多第三方源可以前往校园网联合镜像站查看)的镜像,各系统都可以通过修改用户目录下的 .condarc 文件来使用 TUNA 镜像源。Windows 用户无法直接创建名为 .condarc 的文件,可先执行 conda config --set show_channel_urls yes 生成该文件之后再修改。

注:由于更新过快难以同步,我们不同步pytorch-nightly, pytorch-nightly-cpu, ignite-nightly这三个包。

channels:
  - defaults
show_channel_urls: true
default_channels:
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/msys2
custom_channels:
  conda-forge: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  msys2: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  bioconda: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  menpo: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  pytorch: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  pytorch-lts: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  simpleitk: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  deepmodeling: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/

即可添加 Anaconda Python 免费仓库。

运行 conda clean -i 清除索引缓存,保证用的是镜像站提供的索引。

运行 conda create -n myenv numpy 测试一下吧。

Miniconda 镜像使用帮助

Miniconda 是一个 Anaconda 的轻量级替代,默认只包含了 python 和 conda,但是可以通过 pip 和 conda 来安装所需要的包。

Miniconda 安装包可以到 https://mirrors.tuna.tsinghua.edu.cn/anaconda/miniconda/ 下载。

Ubuntu 软件仓库 和 ROS/ROS2

也可以在镜像站帮助中找到替换方法

Ubuntu https://mirrors.tuna.tsinghua.edu.cn/help/ubuntu/

ROS https://mirrors.tuna.tsinghua.edu.cn/help/ros/

ROS2 https://mirrors.tuna.tsinghua.edu.cn/help/ros2/

@Author: 果壳里的幻想

@Time: 2024.1.24

@Version: 0.1.1

@Remarks: 有任何错误请与果壳里的幻想联系

Logo

瓜分20万奖金 获得内推名额 丰厚实物奖励 易参与易上手

更多推荐