正在 Ubuntu/Vagrant 升级 Python3

Upgrading Python3 on Ubuntu/Vagrant

如何在 Ubuntu 上升级我的 python3 安装?特别是从 3.5.2 --> 3.6.x

这是基本尝试,虽然我也尝试了 removepurge 命令但没有明显效果。

Welcome to Ubuntu 16.04.5 LTS (GNU/Linux 4.4.0-130-generic x86_64)
$ ubuntu@ubuntu-xenial:/vagrant$ python3 --version
Python 3.5.2 
$ sudo apt-get install python3 3.6 --reinstall
... [no errors, lots of output]
$ ubuntu@ubuntu-xenial:/vagrant$ python3 --version
Python 3.5.2

此时我希望看到 Python 3.6.x 作为版本。我在 /usr/bin

中没有看到任何新条目
ubuntu@ubuntu-xenial:/vagrant$ ll /usr/bin | grep python
lrwxrwxrwx  1 root   root         26 May 18  2016 dh_pypy -> ../share/dh-python/dh_pypy*
-rwxr-xr-x  1 root   root       1056 Nov 24  2017 dh_python2*
lrwxrwxrwx  1 root   root         29 May 18  2016 dh_python3 -> ../share/dh-python/dh_python3*
lrwxrwxrwx  1 root   root         23 Dec  4  2017 pdb2.7 -> ../lib/python2.7/pdb.py*
lrwxrwxrwx  1 root   root         23 Nov 28  2017 pdb3.5 -> ../lib/python3.5/pdb.py*
lrwxrwxrwx  1 root   root         31 Mar 23  2016 py3versions -> ../share/python3/py3versions.py*
lrwxrwxrwx  1 root   root         26 May 18  2016 pybuild -> ../share/dh-python/pybuild*
lrwxrwxrwx  1 root   root          9 Nov 24  2017 python -> python2.7*
lrwxrwxrwx  1 root   root          9 Nov 24  2017 python2 -> python2.7*
-rwxr-xr-x  1 root   root    3492656 Dec  4  2017 python2.7*
lrwxrwxrwx  1 root   root          9 Mar 23  2016 python3 -> python3.5*
-rwxr-xr-x  2 root   root    4464400 Nov 28  2017 python3.5*
-rwxr-xr-x  2 root   root    4464400 Nov 28  2017 python3.5m*
lrwxrwxrwx  1 root   root         10 Mar 23  2016 python3m -> python3.5m*
lrwxrwxrwx  1 root   root         29 Nov 24  2017 pyversions -> ../share/python/pyversions.py*

没有直接证据表明安装了任何新东西

ubuntu@ubuntu-xenial:/vagrant$ py3versions -i
python3.5

我只想在此虚拟机上安装 python3 >= 3.6。我 完全 不关心以前的安装、python2、virtualenvs 或任何一般的服务器健康问题,因为这是一个完全独立的开发框。

对于Ubuntu 16.04,您可以使用Felix Krull's deadsnakes PPA

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

或者,您可以使用 J Fernyhough's PPA

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

如果您想在 Ubuntu 16.04

上编译并安装 python 3.6
sudo apt install build-essential checkinstall
sudo apt install libreadline-gplv2-dev libncursesw5-dev libssl-dev libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev
wget https://www.python.org/ftp/python/3.6.0/Python-3.6.0.tar.xz
tar xvf Python-3.6.0.tar.xz
cd Python-3.6.0/
./configure
sudo make altinstall