清华镜像源的使用说明

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

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

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
相关推荐
空气中的臭氧33 分钟前
解决python manage.py shell ModuleNotFoundError: No module named xxx
python·manage.py
b***25112 小时前
电池分选机:新能源时代的品质守护者|深圳比斯特自动化
大数据·人工智能·自动化
IT科技观察3 小时前
金融壹账通推出大模型一体机,加速金融行业AI落地与应用
大数据·人工智能·金融·云计算
狮歌~资深攻城狮5 小时前
ClickHouse进阶技巧:解锁数据处理的高级潜能
大数据·数据库
晨曦5432105 小时前
函数和模式化——python
开发语言·python
Verdure陌矣7 小时前
游戏开发中 C#、Python 和 C++ 的比较
c++·python·游戏·c#
丰锋ff7 小时前
借助 AI 工具使用 Python 实现北京市店铺分布地理信息可视化教程
人工智能·python·信息可视化
java1234_小锋7 小时前
一周学会Pandas2 Python数据处理与分析-Pandas2二维数据结构-DataFrame
数据结构·python·pandas
业财猫CRM7 小时前
“乐企“平台如何重构业财税票全流程生态?
大数据·重构·业界资讯
钡铼技术物联网关7 小时前
下一代楼宇自控的中枢神经:ARM终端的生态
大数据·linux·人工智能