How to install Python 3

Asked

Viewed 260 times

4

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

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

I’m taking a course where I need to use 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.

  • Use Eclipse is best practice to develop, and follow the site https://www.vivaolinux.com.br/artigo/Pydev-Preparando-o-clipse-para-o-Python

1 answer

5


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 package name uses:

apt-cache search <nome do pacote>

In the case of python3 would stay:

sudo apt-get install python3

To check the installation:

 python3 --version

To use python3:

python3 arquivo.py

I hope I’ve helped ^^

  • Just remember also NOT TRYING TO UNINSTALL Python 2 to install Python 3 on Ubuntu (or after installing) - Python2 and 3 may exist side by side. Desisntalar the Python2 will break your system, perhaps irremediably.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.