I am on Ubuntu 11.04 and have Python 2.6 installed. I would like to upgrade to Python 2.7. How should I go about doing this?
2 Answers
If indeed you find you don't have python 2.7 its in the repositories
sudo apt-get install python2.7
You may find, however, that instead of calling python
to compile, having multiple versions will need you to specifically call python2.7
.
You can overwrite this behavior by redirecting the 'python' link in your /usr/bin/ directory to the python2.7 executable. (This may cause problems if you're keeping legacy programs that are expecting 2.6 and are badly coded, however I very much doubt it.)
-
hi thomas, when i typed
python
in the command line, it says i have v2.71. That's great, but why does it show v2.6 of IDLE, the Unity menu, when I typeidle
? Any clues? Jun 6, 2011 at 17:45 -
i wouldn't be surprised if you had 2.6 installed as well, lots of GUIs are written in python, and demand certain versions. i would expect, therefore, that IDLE should have a setting allowing you to choose the python executable it uses? redirect this to /usr/bin/python and you should be back on 2.7 :) Jun 6, 2011 at 17:53
on Ubuntu 16.04, Python 2.7 can not be uninstalled or upgraded to upper versions like 3.8 because many packages in Ubuntu 16.04 depend on Python 2.7, so the only way to use upper version of Python than version 2.7 is to install newer version alongside the built in one, but it is not a straightforward installation and you can not use simply sudo apt-get install python3.8
even when you added corresponding ppa repository, there are many pages over web that reported the errors that occurs, I focus on solution:
Keep in mind also that deadsnakes
PPA was decommissioned for Ubuntu 16.04 (Xenial Xerus). This means that you won’t be able to install Python 3.8 from the deadsnakes
PPA on Ubuntu 16.04. However, you can still install Python 3.8 by building it from source. Here are the steps to do so:
1- Install the required dependencies:
sudo apt-get update 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 libffi-dev zlib1g-dev
2- Change to the /opt
directory and download the Python 3.8 source code:
cd /opt
sudo wget https://www.python.org/ftp/python/3.8.0/Python-3.8.0.tgz
3- Extract the downloaded source code and change to the extracted directory:
sudo tar xzf Python-3.8.0.tgz
cd Python-3.8.0
4- Configure and build Python 3.8:
sudo ./configure --enable-optimizations
sudo make altinstall
and voila:) you can test your new installed Python version by running:
python3.8 --version
lsb_release -cds
to make sure.