清华镜像源的使用说明

清华镜像源主要用于加速软件包的下载和安装,以下是其用法说明:

一、针对不同软件的使用方法

pip(Python 包管理工具):

临时使用:可以在使用

pip install 命令时指定 -i 参数

来使用清华镜像源,例如:

powershell 复制代码
pip install package_name -i https://pypi.tuna.tsinghua.edu.cn/simple

永久设置:

#Windows:在命令提示符中执行

powershell 复制代码
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple

#Linux 和 macOS:在终端中执行

powershell 复制代码
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple

也可以编辑 ~/.pip/pip.conf 文件(如果没有则创建),添加以下内容:

plaintext

powershell 复制代码
 [global]
 index-url = https://pypi.tuna.tsinghua.edu.cn/simple

conda(Anaconda 包管理工具):

临时使用:可以在使用 conda install 命令时指定 -c 参数来使用清华镜像源,

例如:

powershell 复制代码
conda install package_name -c https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/

永久设置:

Windows:在 Anaconda Prompt 中执行

powershell 复制代码
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/ 

powershell 复制代码
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/

Linux 和 macOS:在终端中执行

powershell 复制代码
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/

powershell 复制代码
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/

也可以编辑 ~/.condarc 文件(如果没有则创建),添加以下内容:

plaintext

复制

复制代码
   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/free
   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
     simpleitk: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud

Maven(Java 项目管理工具):

编辑 ~/.m2/settings.xml 文件(如果没有则创建),

在 标签内添加以下内容:

xml

复制

复制代码
 <mirrors>
   <mirror>
     <id>tuna</id>
     <mirrorOf>*</mirrorOf>
     <url>https://mirrors.tuna.tsinghua.edu.cn/maven/</url>
   </mirror>
 </mirrors>

npm(Node.js 包管理工具):

临时使用:可以在使用 npm install 命令时指定 --registry 参数来使用清华镜像源,例如:

powershell 复制代码
npm install package_name --registry=https://registry.npmmirror.com

永久设置:在命令提示符或终端中执行

powershell 复制代码
npm config set registry https://registry.npmmirror.com
相关推荐
cc5725026533 分钟前
2026 秋招直播运营岗位招聘 JD 拆解,数据指标与数据分析能力备考思路
大数据·数据挖掘·数据分析
阡陌数智9 分钟前
LiteLLM 开源网关实践:能力边界与生产环境改造要点
大数据·人工智能·开源·prompt·软件工程
泡海椒18 分钟前
脚本包导入实战:JQuick-Java自定义包引入与别名配置教程
java·开发语言·python
fbbqt19 分钟前
Python模块与包
开发语言·python
数智化码农22 分钟前
半导体制造人力资源数字化选型:适配双用工体系,兼顾合规与人效
大数据·运维·python·制造
电梯界知识分子25 分钟前
江西抚州临川九尊府五层别墅:受限楼梯间里,全黑铝合金观光井道配曳引龙门架的落地记录
大数据·前端·网络·算法·家用电梯
statistican_ABin28 分钟前
中国婚姻与生育观念变迁分析报告
python
清水白石00838 分钟前
别被 `Process.start()` 骗了:Python multiprocessing 从面试题到线上生产的进程启动机制实战
开发语言·python
无风听海1 小时前
深入解析 Elasticsearch 的 match_phrase_prefix与 match_bool_prefix
大数据·elasticsearch·mybatis
愚公移山填海1 小时前
【无标题】
笔记·python·学习·pycharm