How do I install a different Python version using apt-get?
How can I install a different version of Python using apt-get?
Obviously I realise I can install using the source tar ball, however I would prefer not to install from source and instead use the package manager, as that's what it's there for. Surely somewhere reputable builds .deb files for the latest Python releases (why python.org don't is beyond me) that I can reference.
What do I need to do to reference them and what issues might it create when upgrading to the next version?
If there is no way except for building from source, is there a (pseudo) package that I can can install that will provide all of the dependencies needed without having to find and install each individually? So that I don't get:
The necessary bits to build these optional modules were not found:
_bz2 _curses _curses_panel
_dbm _gdbm _lzma
_sqlite3 _ssl _tkinter
readline zlib
Felix Krull runs a PPA offering basically any version of Python (seriously, there is 2.3.7 build for vivid...) for many Ubuntu releases at https://launchpad.net/~deadsnakes/+archive/ubuntu/ppa.
Do the usual:
sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt-get update
sudo apt-get install python3.5
It will not overwrite your existing python3.4
which is still symlinked as python3
.
DON'T change the symlink! There are apparently many system functions that don't work properly with python3.5.
I tried this and afterwards couldn't open a terminal, software updater,...
cd /usr/bin
sudo rm python3
The upgrade to Wily will adapt the meta-package python3
to point to python3.5
. I don't expect any breakage, but at this point the foreign repository is not needed anymore. So to be really safe, you can purge the PPA before doing the upgrade.
This Youtube link helped me to install it.
The steps are:
sudo apt-get install libssl-dev openssl
wget https://www.python.org/ftp/python/3.5.0/Python-3.5.0.tgz
tar xzvf Python-3.5.0.tgz
cd Python-3.5.0
./configure
make
sudo make install
To check if python is installed type python3.5
else:
sudo ln -fs /opt/Python-3.5.0/Python /usr/bin/python3.5
Just follow this steps (tested) :
Step 1 – Install Required Packages
Use the following command to install prerequisites for Python before installing it.
sudo apt-get install build-essential checkinstall
sudo apt-get install libreadline-gplv2-dev libncursesw5-dev libssl-dev libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev
Step 2 – Download Python 3.5.2
Download Python using following command from python official site. You can also download latest version in place of specified below.
cd /usr/src
sudo wget https://www.python.org/ftp/python/3.5.2/Python-3.5.2.tgz
Now extract the downloaded package.
sudo tar xzf Python-3.5.2.tgz
Step 3 – Compile Python Source
Use below set of commands to compile python source code on your system using altinstall.
cd Python-3.5.2
sudo ./configure
sudo make altinstall
make altinstall
is used to prevent replacing the default python binary file /usr/bin/python
.
Step 4 – Check the Python Version
Check the latest version installed of python using below command.
$ python3.5 -V
Python 3.5.2
Source.