树莓派镜像源配置:从"龟速下载"到"光速起飞"的自救指南
家人们谁懂啊!刚拿到树莓派兴冲冲想装软件,结果apt下载像蜗牛爬,pip安装卡到怀疑人生,conda更是直接原地摆烂。折腾了半天才发现,原来是镜像源没配置对!今天就把这份亲测有效的"树莓派提速秘籍"分享出来,让你的小派告别龟速,起飞不是梦!
一、apt源:给系统更新插上"清华火箭"
咱树莓派默认的apt源,那速度简直能急死急性子。想给系统装个软件,进度条能卡到天荒地老,甚至还会半路"失联"。别急,咱直接把它换成清华镜像源,主打一个丝滑!
首先掏出命令行,输入sudo nano /etc/apt/sources.list,打开apt的配置文件。接下来把清华镜像源的地址加进去,这里友情提示:别把系统自带的源全删掉,留着备用才稳妥!修改后的配置长这样:
arduino
deb https://mirrors.tuna.tsinghua.edu.cn/raspberrypi/ bookworm main
deb http://deb.debian.org/debian bookworm main contrib non-free non-free-firmware
deb http://deb.debian.org/debian-security/ bookworm-security main contrib non-free non-free-firmware
deb http://deb.debian.org/debian bookworm-updates main contrib non-free non-free-firmware
保存退出后,再更新一下源,你会发现,原来系统更新也能这么快!
二、pip源:Python包下载不再"卡成PPT"
用pip装Python包的痛,谁用谁知道。有时候一个几百KB的小包,能下载十分钟,还动不动提示超时。这时候就得给pip也安排上"专属加速通道"。
先输入mkdir -p $HOME/.pip && nano $HOME/.pip/pip.conf,创建并打开pip的配置文件,然后把下面这段代码粘贴进去:
ini
[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
[install]
extra-index-url =
https://mirrors.aliyun.com/pypi/simple/
https://pypi.org/simple
配置完之后再试一次pip install,那速度,从"PPT加载"直接变成"秒开视频",爽到飞起!
三、conda源:数据分析党再也不用等哭
对于需要用conda搞数据分析的朋友来说,默认源的速度能让人直接emo。别慌,清华镜像源照样能拯救你!
依次输入这几条命令,给conda安排上清华的"专属通道":
arduino
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
conda config --set channel_priority strict
conda config --set show_channel_urls yes
最后输入conda config --show channels检查一下通道,确认配置成功,以后conda装包再也不用边等边摸鱼了!
四、安装miniforge:给conda装个"国产加速器"
如果你的树莓派还没装miniforge,那可得赶紧安排上!不过直接从GitHub下载,速度可能有点拉胯,贴心如我,给你们准备了加速链接!
- 先下载安装脚本,要是GitHub链接下不动,直接换清华的加速链接:
bash
# GitHub链接
wget https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-Linux-aarch64.sh
# 加速链接
wget https://mirrors.tuna.tsinghua.edu.cn/github-release/conda-forge/miniforge/LatestRelease/Miniforge3-Linux-aarch64.sh
- 给脚本加个可执行权限:
chmod +x Miniforge3-Linux-aarch64.sh - 运行安装脚本:
./Miniforge3-Linux-aarch64.sh -b - 把它加到PATH环境里,不然系统找不到:
bash
echo 'export PATH="$HOME/miniforge3/bin:$PATH"' >> ~/.bashrc
source ~/.bashrc
- 最后初始化conda再重启一下:
conda init && sudo reboot(悄悄说,原文里的指令多打了个conda,咱可别踩这个坑)
配置完这一套,你的树莓派直接变身"下载小能手",不管是系统更新、装Python包还是搞数据分析,都能一路畅通。快收藏起来,下次再遇到下载龟速的情况,直接掏出这份秘籍自救!转成markdown代码