清华镜像源的使用说明

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

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

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
相关推荐
Book_熬夜!5 分钟前
Python基础(六)——PyEcharts数据可视化初级版
开发语言·python·信息可视化·echarts·数据可视化
我的运维人生14 分钟前
利用Python与Ansible实现高效网络配置管理
网络·python·ansible·运维开发·技术共享
毕设木哥21 分钟前
计算机专业毕业设计推荐-基于python的汽车汽修保养服务平台
大数据·python·计算机·django·汽车·毕业设计·课程设计
lupai1 小时前
盘点实用的几款汽车类接口?
大数据·人工智能·汽车
m0_638971342 小时前
ARM概念
python
夜幕龙2 小时前
robomimic基础教程(三)——自带算法
人工智能·python·算法·机器人
千天夜3 小时前
python本地进程通讯----共享内存变量
python
DengHua22033 小时前
python定时发送邮件的功能如何实现自动化?
python·api接口·邮件营销·邮件群发·邮件接口·触发式邮件·验证码邮件
Teleger3 小时前
使用python来保存键盘输入情况,可保存到sqlite3数据库
python·conda
金智维科技官方3 小时前
高效财税自动化软件的特点与优势
大数据·人工智能·自动化·rpa