清华镜像源的使用说明

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

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

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
相关推荐
都叫我大帅哥1 小时前
Python的Optional:让你的代码优雅处理“空值”危机
python
火火PM打怪中2 小时前
产品经理如何绘制服务蓝图(Service Blueprint)
大数据·产品经理
曾几何时`3 小时前
基于python和neo4j构建知识图谱医药问答系统
python·知识图谱·neo4j
写写闲篇儿5 小时前
Python+MongoDB高效开发组合
linux·python·mongodb
杭州杭州杭州6 小时前
Python笔记
开发语言·笔记·python
路人蛃8 小时前
通过国内扣子(Coze)搭建智能体并接入discord机器人
人工智能·python·ubuntu·ai·aigc·个人开发
qiqiqi(^_×)8 小时前
卡在“pycharm正在创建帮助程序目录”
ide·python·pycharm
Ching·9 小时前
esp32使用ESP-IDF在Linux下的升级步骤,和遇到的坑Traceback (most recent call last):,及解决
linux·python·esp32·esp_idf升级
吗喽1543451889 小时前
用python实现自动化布尔盲注
数据库·python·自动化
hbrown10 小时前
Flask+LayUI开发手记(十一):选项集合的数据库扩展类
前端·数据库·python·layui