Ubuntu中安裝python3.6踩坑

tzkj_wdz發表於2020-11-16

安裝的相關命令

更新

sudo apt-get update

安裝python3.6

apt-get install software-properties-common
add-apt-repository ppa:jonathonf/python-3.6
apt-get update
apt-get install python3.6

執行add-apt-repository ppa:jonathonf/python-3.6時報錯 403 Forbidden [IP: ~]

Hit:1 http://mirrors.cloud.aliyuncs.com/ubuntu focal InRelease
Hit:2 http://mirrors.cloud.aliyuncs.com/ubuntu focal-updates InRelease
Hit:3 http://mirrors.cloud.aliyuncs.com/ubuntu focal-security InRelease
Hit:4 http://ppa.launchpad.net/deadsnakes/ppa/ubuntu focal InRelease
Err:5 http://ppa.launchpad.net/jonathonf/python-3.6/ubuntu focal InRelease
403 Forbidden [IP: 91.189.95.83 80]
Reading package lists… Done
E: Failed to fetch http://ppa.launchpad.net/jonathonf/python-3.6/ubuntu/dists/focal/InRelease 403 Forbidden [IP: 91.189.95.83 80]
E: The repository ‘http://ppa.launchpad.net/jonathonf/python-3.6/ubuntu focal InRelease’ is not signed.
N: Updating from such a repository can’t be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.

解決辦法

進入/etc/apt/sources.list.d檔案把有關python3.6檔案,以list結尾的檔案刪除。或者修改為.bak結尾

root@iZuf6b77csetgh3jg7sw2tZ:~# cd /etc/apt/sources.list.d
root@iZuf6b77csetgh3jg7sw2tZ:/etc/apt/sources.list.d# ls
deadsnakes-ubuntu-ppa-focal.list deadsnakes-ubuntu-ppa-focal.list.save jonathonf-ubuntu-python-3_6-focal.list jonathonf-ubuntu-python-3_6-focal.list.save
root@iZuf6b77csetgh3jg7sw2tZ:/etc/apt/sources.list.d# sudo mv jonathonf-ubuntu-python-3_6-focal.list jonathonf-ubuntu-python-3_6-xenial.list.bak
root@iZuf6b77csetgh3jg7sw2tZ:/etc/apt/sources.list.d# ls
deadsnakes-ubuntu-ppa-focal.list deadsnakes-ubuntu-ppa-focal.list.save jonathonf-ubuntu-python-3_6-focal.list.save jonathonf-ubuntu-python-3_6-xenial.list.bak
root@iZuf6b77csetgh3jg7sw2tZ:/etc/apt/sources.list.d# sudo mv deadsnakes-ubuntu-ppa-focal.list deadsnakes-ubuntu-ppa-focal.list.bak

在進行

sudo apt-get update

root@iZuf6b77csetgh3jg7sw2tZ:/etc/apt/sources.list.d# cd ~
root@iZuf6b77csetgh3jg7sw2tZ:~# sudo apt-get update
Hit:1 http://mirrors.cloud.aliyuncs.com/ubuntu focal InRelease
Hit:2 http://mirrors.cloud.aliyuncs.com/ubuntu focal-updates InRelease
Hit:3 http://mirrors.cloud.aliyuncs.com/ubuntu focal-security InRelease
Reading package lists… Done

重新安裝

查了其他大哥的方法,用sudo add-apt-repository ppa:deadsnakes/ppa成功安裝

sudo add-apt-repository ppa:deadsnakes/ppa
apt-get update
apt-get install python3.6

相關文章