步骤1:确认Python3的版本
在卸载Python3之前,我们需要确认正在使用的Python3的版本。可以使用以下命令来查看Python3的版本:
python3 --version
步骤2:卸载Python3
卸载Python3可以使用以下命令:
sudo apt-get --purge remove python3
步骤3:清理残留文件
在卸载Python3之后,可能会残留一些文件。为了彻底清理,我们可以使用以下命令:
sudo apt-get autoremove
步骤2出现以下错误
/bin/sh: 1: /usr/bin/apt-listchanges: not found
E: 子进程 /usr/bin/apt-listchanges --apt || test $? -lt 10 返回了一个错误号 (1)
E: Failure running script /usr/bin/apt-listchanges --apt || test $? -lt 10
解决办法
1、直接进到/usr/bin,删除了py3clean和py3compile
选项1:
请试试:
sudo apt purge -f apt-listchanges
然后尝试:
sudo apt install -f apt-listchanges
选项2:
请试试:
sudo dpkg --remove apt-listchanges
然后尝试:
sudo apt install -f apt-listchanges
选项3:
请试试:
sudo mv /etc/apt/apt.conf.d/20listchanges /etc/apt/apt.conf.d/20listchanges.bak
然后尝试:
sudo apt update && sudo apt upgrade
然后重启,继续执行步骤三
安装旧版本
1.更新树莓派系统
sudo apt-get update
sudo apt-get upgrade -y
2.安装python依赖环境
sudo apt-get install build-essential libsqlite3-dev sqlite3 bzip2 libbz2-dev
3.下载python3.7.3版本进行解压,这里你要用什么版本就下载什么版本即可。
wget https://www.python.org/ftp/python/3.7.3/Python-3.7.3.tgz
tar zxvf Python-3.7.3.tgz
4.安装编译
cd Python-3.7.3
sudo ./configure && sudo make && sudo make install
5.新链接建立
sudo ln -s /usr/bin/python3 /usr/bin/python