Как сделать python 3 основным ubuntu
Перейти к содержимому

Как сделать python 3 основным ubuntu

  • автор:

Installing Python 3.8.3 on Ubuntu 16.04, change the default version of python to the new version, and why is my terminal not working.

It was a long-winded process for me as a newbie when I tried to install python 3.8 on my computer. I am sharing my experience about what worked while installing, changing default versions and fixing the terminal that temporarily stopped working.

How to install Python 3.8 on Ubuntu 16.04?

Step 1: APT automates the retrieval, configuration and installation of software packages. Type these two commands in your terminal and hit enter each time.

Step 2: PPA (Personal Package Archive) are used to add a software to your Ubuntu. They cut down on time taken to install the software from the original source. PPA is an easy way to update a program via someone, in this case I am using deadsnakes PPA. Type the following command and hit enter.

Step 3: Once it is enabled, install Python 3.8 by typing the following command.

Step 4: Check the version by the following command. Your computer will display the new installed python version.

Python is installed. But wait! You are not done yet.

How to update default Python version on Ubuntu?

After installing new version of python 3.8, you will notice that if you type python in your terminal, it will still show you the old version of python. This means that you must make the following changes to allow the computer to be able to use new installed python version. Here are the steps that I took and they worked for me:

Step 1: To view the different versions on your computer:

Step 2: Copy the version you want. I my case, I copied /usr/bin/python3.8

Step3: Go to Home and type Shift+H to view hidden files

Step 4: Open .barshrc file and scroll to the end. Paste the copied python version on the last line. This is how it looks: alias python = “usr/bin/python3.8”.

Step 5: Close the terminal and open it again. It is important to close the terminal to see the applied changes. Type the following command

You will see the default python as the new version .

Another way to update Python versions on Ubuntu.

This did not work for me. But might work for you.

Step 1: Install Python3.8. as mentioned above.

Step 2: Type the following commands. On the first line use your previous version(in my case its python3.5) and set the priority number to 1. On the second line use the new installed python version and set the priority to 2. According to Ubuntu <priority> is an integer; options with higher numbers have higher priority in automatic mode.

sudo update-alternatives —config python3

How to fix the broken terminal?

So while changing the default version of python, I accidentally typed the wrong version numbers of python in the terminal and went ahead with the changes. Somehow this stopped the terminal and I was no longer able to open the terminal. I tried CTRL+ALT+T as well as restarting the computer but the terminal window did not open.

  1. Press Ctrl+Alt+F1 to open xterm. XTERM is a terminal emulator for the X Window System. It comes with Ubuntu as well.
  2. Enter username.
  3. Enter password.
  4. Type this command:

5. Select option 1.

6. At last type Ctrl+Alt+F7 to return to GUI

My terminal was up and running again.

If you find these guidelines useful, do let me know in the comments below. Have fun learning!

How can I change the default python on my Ubuntu 20.04 to Python3.8?

Complains it cannot find /usr/bin/python3.8, buuuuut:

/usr/bin/python /usr/bin/python3.8 /usr/bin/python3-pasteurize /usr/bin/python2 /usr/bin/python3.8-config /usr/bin/python3-unidiff /usr/bin/python2.7 /usr/bin/python3-config /usr/bin/python3 /usr/bin/python3-futurize

How do I get bash to find see /usr/bin/python3.8?

4 Answers 4

The correct way is sudo apt install python-is-python3 — it effectively does a symlink, but it also keeps pace with future updates; so if your ubuntu distribution moves to say Python 3.9, the manual symlink will no longer work, but the package makes sure it is still valid.

Firstly to answer your question, your approach should work, I think the path you’ve given in your alias needs the / preceding the path so the command should be alias python=’/usr/bin/python3.8′ , this would indeed need to go into your

/.bashrc file assuming you are using bash.

Secondly, Ubuntu has a really nice method of setting default binaries globally rather than messing with dot config files as depicted here: update-alternatives

a better solution may be to simply run:

This will ensure you have the version of python in use that you intend, everywhere.

Change the Python3 default version in Ubuntu

I am using Ubuntu 16.04 LTS . I have python3 installed. There are two versions installed, python 3.4.3 and python 3.6 . Whenever I use python3 command, it takes python 3.4.3 by default. I want to use python 3.6 with python3 .

python3 —version shows version 3.4.3

I am installing ansible which supports version > 3.5 . So, whenever, I type ansible in the terminal, it throws error because of python 3.4

9 Answers 9

From the comment:

Will show you an error:

You need to update your update-alternatives , then you will be able to set your default python version.

Set python3.6 as default.

Or use the following command to set python3.6 as default:

You can achieve this by applying below simple steps —

Check python version on terminal: python —version

Execute this command to switch to python 3.6:

Check python version: python —version

Kusalananda's user avatar

if you have multiple version of python in your system. You just need to update the symbolic link of python inside /usr/bin/

In above example if you see the output of python —version you will get python2.7

Now update the python symlink using below command-

IRSHAD's user avatar

Using these commands can help you:

  1. check the version of python: ls /usr/bin/python*
  2. alias: alias python=’/usr/bin/pythonxx’ (add this to .

Newt's user avatar

/.bashrc. Then you will make it work forever.

First check that you have a python3.6 folder?

If you have "python3.6" folder, you are good to go. Now update-alternatives

then update new config for python3

Finally, check default python3 version:

Stewart's user avatar

Create symlink for /usr/bin/python3. In my LinuxMint:

Adersh Ps's user avatar

An easy answer would be to add an alias for python3.6.

Just add this line in the file

/.bashrc : alias python3=»python3.6″ , then close your terminal and open a new one. Now when you type python3 xxx it gets translated to python3.6 xxx .

This solution fixes your problem without needing to tweak your system too heavily.

EDIT :

As Mikael Kjær pointed out, this is a misconfiguration of ansible with your system.

Set the ansible_python_interpreter configuration option to /usr/bin/python3. The ansible_python_interpreter configuration option is usually set per-host as an inventory variable associated with a host or group of hosts:

As seen here about the config file :

Changes can be made and used in a configuration file which will be processed in the following order:

Переключение интерпретатора Python, используемого по умолчанию, с версии 2.7 на 3.6 в Ubuntu 18.04

В текущий момент язык Python находится в процессе транзита с версии 2.x на 3.x, что влияет на корректность исполнения приложений, которые рассчитывают на ту или иную версию интерпретатора. Обычно, проблемы нет, если используется среда VirtualEnv, когда вы можете выбрать требуемое окружение при его создании, но приложения, которые выполняются вне VirtualEnv могут рассчитывать на ту или иную версию Python. В данной заметке мы рассмотрим простые шаги, как изменить версию Python, используемую по умолчанию, в Ubuntu Linux 18.04.

Для начала выясните какая версия используется в настоящий момент:

Мы видим, что в настоящее время в системе используется интерпретатор Python версии 2.7. Предположим, что вам требуется python 3.6. Проверьте, что он доступен:

Если в процессе выполнения вышеуказанной команды интерпретатор не найден, используйте apt для его установки:

Теперь вы можете переключить версию интерпретатора, выполнив команду ln :

Запросите версию python повторно:

Как можно видеть, версия интерпретатор изменена на требуемую. Данное решение полезно, когда в систему устанавливается программное обеспечение из сторонних пакетов, которое рассчитывает на то, что по-умолчанию используется Python версии 3.

Добавить комментарий

Ваш адрес email не будет опубликован. Обязательные поля помечены *