How to install Python 3

4

I'm new to Ubuntu and I'm learning Python.

I have installed Pyhton 2.7.12 on my pc and would like to know how I can upgrade to version 3.

I'm doing a course where I need to make use of a lib.

import urllib.request

But the following error appears:

import urllib.request
ImportError: No module named request

Looking at the internet I saw some comments saying that for this to work I needed to run the file with python 3 installed.

I would like to know how to install python 3 to fix this error.

    
asked by anonymous 02.09.2016 / 12:44

1 answer

6

In Ubuntu one of the ways to install any package is to use apt-get:

sudo apt-get install <nome do pacote>

If you do not know the name of the package you use:

apt-cache search <nome do pacote>

In the case of python3 would be:

sudo apt-get install python3

To check the installation:

 python3 --version

To use python3:

python3 arquivo.py

I hope I have helped ^^

    
02.09.2016 / 12:49