清华镜像源的使用说明

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

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

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
相关推荐
小白学大数据17 分钟前
Python爬虫常见陷阱:Ajax动态生成内容的URL去重与数据拼接
爬虫·python·ajax
2401_841495641 小时前
【计算机视觉】基于复杂环境下的车牌识别
人工智能·python·算法·计算机视觉·去噪·车牌识别·字符识别
Adorable老犀牛2 小时前
阿里云-ECS实例信息统计并发送统计报告到企业微信
python·阿里云·云计算·企业微信
倔强青铜三2 小时前
苦练Python第66天:文件操作终极武器!shutil模块完全指南
人工智能·python·面试
倔强青铜三2 小时前
苦练Python第65天:CPU密集型任务救星!多进程multiprocessing模块实战解析,攻破GIL限制!
人工智能·python·面试
Panda__Panda2 小时前
docker项目打包演示项目(数字排序服务)
运维·javascript·python·docker·容器·c#
zskj_qcxjqr2 小时前
七彩喜艾灸机器人:当千年中医智慧遇上现代科技
大数据·人工智能·科技·机器人
Lris-KK3 小时前
力扣Hot100--94.二叉树的中序遍历、144.二叉树的前序遍历、145.二叉树的后序遍历
python·算法·leetcode
zy_destiny4 小时前
【工业场景】用YOLOv8实现抽烟识别
人工智能·python·算法·yolo·机器学习·计算机视觉·目标跟踪
(●—●)橘子……4 小时前
记力扣2009:使数组连续的最少操作数 练习理解
数据结构·python·算法·leetcode