How to install python 3

I just started using Ubuntu and got lost. I would like to install Python 3. So, I downloaded it. Extract it to my desctop folder. And typed:

./configure make make test sudo make install 

Well, that should have installed Python 3 as the main interpreter. Byt, if I write python, Python 2.7 appears.

I tried to find where Python 3 is located, but failed. The search reveals a lot of elements, but if you are new to Ubuntu, that doesn't help much.

If Python 3 is not my main language, that's fine. But could you suggest: 1. Where is the folder with Python 3. 2. How to start it.

+4
source share
2 answers

You run it with python3 or even specifying the full version, i.e. python-3.2 .

The reason for this is that Ubuntu, since other unix systems use python internally, so modifying the standard python executable is usually bad. So installing python 3 will not replace the existing symbolic link.

+9
source

First, install it correctly via Synaptic or apt-get:

 $ sudo apt-get install python3 

Secondly, use python3 to execute it from the terminal. If you are writing .py files, insert shebang in the first line of the file:

 #!/usr/bin/env python3 print("Hello world!") 

or

 #!/usr/bin/python3 print("Hello world!") 

To run them without typing python3 behind it, run chmod u+x in the file.

Then you are good to go. :)

+8
source

Source: https://habr.com/ru/post/1437052/


All Articles