镜像源详解

一、镜像源来源

镜像的来源,一般指国内存放国外软件镜像的网站、服务器。为啥需要镜像源,在国内由于各种原因下载或更新国外的软件(比如python)网速特别慢甚至连不上。Ubuntu、Python、Nodejs、MySQL、Git、Chromium、Docker、Homebrew 等一系列的常用开源系统、软件都是国外开发的,下载地址位于国外,从国内访问、下载、更新。所以找个镜像网站就解决了。
 

二、镜像源常用代码

#显示镜像源
conda config --show-sources

#显示镜像源
conda config --show channels

#删除镜像源
conda config --remove-key channels #删除所有的镜像源,恢复到默认
conda config --remove channels [urls] #删除指定的镜像源

#添加新镜像
conda config --add channels http://pypi.douban.com/simple/ 
conda config --add channels http://mirrors.aliyun.com/pypi/simple/ 
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --set show_channel_urls yes


#国内常用源镜像地址:

清华:https://pypi.tuna.tsinghua.edu.cn/simple

阿里云:https://mirrors.aliyun.com/pypi/simple/

中国科技大学: https://pypi.mirrors.ustc.edu.cn/simple/

华中理工大学:https://pypi.hustunique.com/

山东理工大学:https://pypi.sdutlinux.org/

豆瓣:https://pypi.douban.com/simple/



三、临时使用

pip

临时使用

可以在使用pip的时候加参数-i Simple Index 
例如:pip install -i Simple Index numpy,这样就会从清华这边的镜像去安装numpy库。

pip install -i https://pypi.tuna.tsinghua.edu.cn/simple numpy

永久修改

  • Linux下,修改 ~/.pip/pip.conf (没有就创建一个), 修改 index-url至tuna,内容如下:pip
  •  [global]
     index-url = https://pypi.tuna.tsinghua.edu.cn/simple
    

conda 

conda是Anaconda中用来安装python包的工具。在Anaconda中将镜像分为两类,一类是官方的python包,放在anaconda中;另一类是第三方的python包,放在conda-forge中。

临时使用

采用conda 安装python包时,可以使用以下命令:

conda install -c https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/linux-64 joblib

在conda-forge中安装jieba第三方的Python包

conda install -c https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/linux-64 jieba

其中参数-c指定了镜像源的通道

永久修改

conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --set show_channel_urls yes

  • 6
    点赞
  • 21
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
树莓派的最新版本 Bullseye 使用的是 Debian 11 系统,下面是更换树莓派 Bullseye 版本的国内镜像源的详细步骤: 1. 打开终端,进入树莓派系统的命令行界面。 2. 备份原有的源列表文件: ``` sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak ``` 3. 使用编辑器(如 nano)打开源列表文件: ``` sudo nano /etc/apt/sources.list ``` 4. 删除原有的源列表内容,并添加以下内容(清华大学镜像源): ``` deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye main contrib non-free deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye main contrib non-free deb https://mirrors.tuna.tsinghua.edu.cn/debian-security bullseye-security main contrib non-free deb-src https://mirrors.tuna.tsinghua.edu.cn/debian-security bullseye-security main contrib non-free deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye-updates main contrib non-free deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye-updates main contrib non-free ``` 5. 保存文件并退出编辑器(按 Ctrl + X,然后按 Y 确认保存)。 6. 运行以下命令更新源列表: ``` sudo apt update ``` 7. 运行以下命令升级系统: ``` sudo apt upgrade ``` 8. 完成!你的树莓派系统 Bullseye 版本现在已经更换为国内的镜像源。 请注意,根据你所使用的树莓派系统版本,可能需要修改上述命令中的 "bullseye" 为对应的版本名。确保在更换镜像源时,你选择的是适用于你的树莓派系统版本的镜像源

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值