在Ubuntu / Vagrant上升级Python3

时间:2018-08-26 17:55:06

标签: python-3.x ubuntu package apt

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

这是基本的尝试,尽管我也尝试了var images = ['/images/sc3.png', '/images/sc4.png', '/images/sc5.png', '/images/sc6.png', '/images/sc7.png'], i = 0; var yesImage = images[0]; var noImage = images[1]; var equalityImage = images[2]; var yesCount = 0; var noCount = 0; function selectImageBasedOnYesAndNoCount() { if (yesCount === noCount) { return equalityImage; } else if (yesCount > noCount) { return yesImage; } else { return noImage; } } function updateBackground() { var imageUrl = selectImageBasedOnYesAndNoCount(); $("#background").css("background-image", "url("+ imageUrl +")"); } $("#yes").click(function() { yesCount++; updateBackground(); } $("#no").click(function() { noCount++; updateBackground(); } remove命令,但没有明显效果。

purge

目前,我希望将Python 3.6.x作为版本。我没有在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

中看到任何新条目
/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*

我只想在此虚拟机上安装python3> = 3.6。我完全不关心先前的安装,python2,virtualenvs或任何一般的服务器健康方面的东西,因为这是一个完全隔离的开发工具。

1 个答案:

答案 0 :(得分:1)

对于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