It's my first time using ubuntu so I don't know how to use it very well yet... How can i install python 3.5.2 ? It has already the version 2.7.12 . My Ubuntu version is Ubuntu 16.04 LTS (desktop).
2 Answers
Basic process:
sudo apt-get update
sudo apt-get install python3
If you want a very specific version:
sudo apt-cache show python3
sudo apt-get install python3=3.5.1*

- 155
- 6

- 323
-
2I get
E: Unable to locate package python3=
when I run your suggested command. Are you show that is right? – Charlie Parker Dec 16 '16 at 07:09 -
1
-
-
5this still doesn't work for me I get
E: Version '3.5.1*' for 'python3' was not found
– Charlie Parker Feb 08 '17 at 16:00 -
1@CharlieParker, originally I'd written "python3==3.5.1*", which is why you got that "unable to locate" error. Note the two equals signs. – 300D7309EF17 Feb 08 '17 at 16:00
-
1@tedder42 ah ok. I've ran it with one equal sign and the star too and it still doesn't work. Does it work for you? Not sure if the fact I'm inside a docker container makes any difference but its unable to find the python version. What am I suppose to see with
apt-cache show python3
? – Charlie Parker Feb 08 '17 at 16:03 -
1
-
@JibuJames what's available has changed in two years. What version of Ubuntu are you using? Right now it looks like two
3.6.*
versions are installable from a generic 18.04 install, and3.5.1-3
is available from a generic 16.04 install. – 300D7309EF17 Jun 29 '19 at 16:56 -
this does not work for Ubuntu 16.04, since the python version in the repos is 3.5.1 – Him Aug 14 '19 at 16:22
As you must have already noticed that Ubuntu 16.04 has 'python 2.7.12' by default. To check the default python version, run below line
$ python -V
it should return 'Python 2.7.12'
It is recommended that we don't try to modify/uninstall this default package of python because there could be many other system files/applications depending on it, and it might create some unexpected errors or issues if we uninstall this default python package.
So, to use the latest version of python, it would be better to go for creating a virtual environment ('virtualenv'). This is a module inside python which facilitates us to use multiple python versions on the same system.
Step-1: First install python3 -
$ sudo apt-get update
$ sudo apt-get install python3
Step-2: Now install 'virtualenv'-
$ pip install virtualenv
Step-3: Now set the path of virtualenv to your desired directory. lets first create a desired directory-
$ mkdir MYENV
it will create a folder in the current directory with the name 'MYENV'
Step-4: set the path of virtualenv to the created(desired) directory-
$ sudo virtualenv -p python3 MYENV
Step-5: Activate the virtualenv
$ source MYENV/bin/activate
done.. you should be able to get (MYENV) as prefix in the terminal command line. Now run below command
$ python -V
it should return 'python 3.5.2'

- 201
- 2
- 3
-
-
1Few remarks : 1/ No need to install python3, it's already available in Ubuntu 16.04. 2/ No need to install virtualenv. You can spin up a virtualenv using the recommanded
python3 -m venv MYVENV
. So basically all you have to type ispython3 -m venv MYVENV && source MYVENV/bin/activate
– Antwan Aug 18 '17 at 19:16
python3
... – Zanna Jul 13 '16 at 11:423.5.1-3
on my system – grooveplex Jul 13 '16 at 12:11however how can I update to the 3.5.2 version? i will start learning with a book that has that version...
– Rui Miranda Jul 13 '16 at 12:45sudo apt install idle3
) if the book recommends) – Zanna Jul 13 '16 at 13:46