系统更新源是用于对Linux系统本身进行升级更新的软件仓库,树莓派系统更新源配置在(/etc/apt/sources.list.d/raspi.list)里,所以只要修改这个文件,使用国内的镜像服务器,替换掉默认的服务器则可。
执行命令如下:
sudo vi /etc/apt/sources.list.d/raspi.list
将原来的内容全部删除掉后,加上如下:
deb https://mirror.tuna.tsinghua.edu.cn/raspberrypi/ bullseye main
deb-src https://mirror.tuna.tsinghua.edu.cn/raspberrypi/ bullseye main
保存退出则可。
软件安装源是用于通过apt命令安装与更新其它软件的的软件仓库,树莓派系统更新源配置在(/etc/apt/sources.list)里,所以只要修改这个文件,使用国内的镜像服务器,替换掉默认的服务器则可。
执行命令如下:
sudo vi /etc/apt/sources.list
将原来的内容全部删除掉后,加上如下:
deb https://mirror.tuna.tsinghua.edu.cn/raspbian/raspbian/ bullseye main contrib non-free rpi firmware
deb-src https://mirror.tuna.tsinghua.edu.cn/raspbian/raspbian/ bullseye main contrib non-free rpi firmware
保存退出则可。
pip 是 Python 标准库中的一个包,这个包是用来管理 Python 第三方库的,所以当我们用pip去安装第三方python库的时候就会用到pip镜像。注意 树莓派里的pip不一定是默认安装的,如果你没有安装python和pip工具,那么你需要先安装好。
sudo apt install python3
sudo apt install python3-pip
然后用pip -v config list命令可以看到pip源可以被配置在以下地方:
xxx@raspberrypi:~ $ pip -v config list
For variant 'global', will try loading '/etc/xdg/pip/pip.conf'
For variant 'global', will try loading '/etc/pip.conf'
For variant 'user', will try loading '/home/xxx/.pip/pip.conf'
For variant 'user', will try loading '/home/xxx/.config/pip/pip.conf'
For variant 'site', will try loading '/usr/pip.conf'
我们创建site所指向的配置文件/usr/pip.conf并将以下内容写入这个文件则可:
[global]
index-url = https://pypi.mirrors.ustc.edu.cn/simple/
extra-index-url = https://pypi.tuna.tsinghua.edu.cn/simple
https://mirrors.aliyun.com/pypi/simple
hppts://pypi.douban.com/simple
[install]
trusted-host=
pypi.tuna.tsinghua.edu.cn
mirrors.aliyun.com
pypi.douban.com
pypi.mirrors.ustc.edu.cn
ssl_verify: false
sudo apt-get update
sudo apt-get upgrade //访问源列表,读取软件列表,然后保存在本地。
pip3 install -U pip //升级-U指定的PIP库到最新版本,也可以替换成任何想要的PYTHON库
树莓派软件仓库一般分成以下5种,对应以下图片中的5个目录:
main:官方支持的符合 DFSG 规范的软件
contrib:带有非自由依赖关系的 DFSG 兼容软件
non-free:非 DFSG 兼容软件
firmware:官方固件,非开源
rpi:Debian armhf testing distribution for Raspberry Pi
配置项格式如下:
deb <软件源地址> <主版本代号> [软件仓库1] [软件仓库2] [软件仓库3] ...
deb-src <软件源地址> <主版本代号> [软件仓库1] [软件仓库2] [软件仓库3] ...