Обновить python linux mint

How to Install Python 3.11 on Linux Mint 21

On this tutorial, we will focus on how to install Python 3.11 on Linux Mint 21. Python is among the many programming languages that are available for use. These languages are often used to develop programs that are utilized by computers to perform certain tasks. Since our main focus is Python, its latest release is Python 3.11, it is both easy to learn and use. This language is often utilized in instances such as Artificial Intelligence, Graphical User Interface applications, Robotics as well as machine learning and many more. Furthermore, it works well with other programming languages including Java, C and C++. The following features better describes Python 3.11;

  • Error tracebacks have been improved to be more informative
  • Code is executed much faster
  • The syntax for asynchronous tasks is much nicer
  • There are new typing features for better typing support from Python

The above are just but a few features of the many that Python 3.11 bags. We will learn more as we proceed with out tutorial as shown below.

How to Install Python 3.11 on Linux Mint 21

We can now embark on how to install Python 3.11 on Linux Mint. Having looked at the brief introduction on what Python is and what it does, let’s continue to look at how the whole process unfolds below;

Step 1. Update your System

Our first step is to ensure that the system is up to date. To do so, run the following commands consecutively;

sudo apt update sudo apt upgrade

Below is how the output should look like;

[email protected]:~$ sudo apt update && sudo apt upgrade [sudo] password for val: Hit:1 http://archive.ubuntu.com/ubuntu jammy InRelease Get:2 http://security.ubuntu.com/ubuntu jammy-security InRelease [110 kB] Get:3 http://archive.ubuntu.com/ubuntu jammy-updates InRelease [114 kB] Ign:4 http://packages.linuxmint.com vanessa InRelease Hit:5 http://packages.linuxmint.com vanessa Release Get:7 http://archive.ubuntu.com/ubuntu jammy-backports InRelease [99.8 kB] Fetched 324 kB in 1s (385 kB/s) Reading package lists. Done Building dependency tree. Done Reading state information. Done All packages are up to date. Reading package lists. Done Building dependency tree. Done Reading state information. Done Calculating upgrade. Done The following packages were automatically installed and are no longer required: linux-headers-5.15.0-43 linux-headers-5.15.0-43-generic linux-image-5.15.0-43-generic linux-modules-5.15.0-43-generic linux-modules-extra-5.15.0-43-generic Use 'sudo apt autoremove' to remove them. 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

Install the necessary dependencies, by running the command shown below;

sudo apt-get install wget build-essential libreadline-dev libncursesw5-dev libssl-dev libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev libffi-dev zlib1g-dev -y

Step 2. Download Python 3.11 to your System

For this step we will need wget in order to download the Python 3.11 file to your system. Hence the need to have wget command installed on your system as follows;

Читайте также:  Посмотреть чем занят порт линукс

The output below shows that wget is already installed in the system.

[email protected]:~$ sudo apt install wget [sudo] password for val: Reading package lists. Done Building dependency tree. Done Reading state information. Done wget is already the newest version (1.21.2-2ubuntu1). The following packages were automatically installed and are no longer required: linux-headers-5.15.0-43 linux-headers-5.15.0-43-generic linux-image-5.15.0-43-generic linux-modules-5.15.0-43-generic linux-modules-extra-5.15.0-43-generic Use 'sudo apt autoremove' to remove them. 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

We can then proceed to utilize the wget command to download Python 3.11 to our system.

wget https://www.python.org/ftp/python/3.11.1/Python-3.11.1.tar.xz

Check below for how the output should look like;

[email protected]:~$ wget https://www.python.org/ftp/python/3.11.1/Python-3.11.1.tar.xz --2022-12-21 12:26:27-- https://www.python.org/ftp/python/3.11.1/Python-3.11.1.tar.xz Resolving www.python.org (www.python.org). 146.75.120.223, 2a04:4e42:8e::223 Connecting to www.python.org (www.python.org)|146.75.120.223|:443. connected. HTTP request sent, awaiting response. 200 OK Length: 19856648 (19M) [application/octet-stream] Saving to: ‘Python-3.11.1.tar.xz’ Python-3.11.1.tar.xz 100%[================================================================================================================>] 18.94M 57.6MB/s in 0.3s 2022-12-21 12:26:28 (57.6 MB/s) - ‘Python-3.11.1.tar.xz’ saved [19856648/19856648]

Extract the downloaded tar.xz file;

Change directory to where the extracted file is, then compile with the command that follows;

cd Python-3.11.1 ./configure --enable-optimizations

Proceed to install and build Python by utilizing the command shown below. The following command might take sometime once executed, hence be patient;

Step 3. Set the Python Version as Default

The command that follows below helps to create a symbolic link to Python3;

sudo update-alternatives --install /usr/bin/python3 python3 /usr/local/bin/python3.11 1 python3 --version

The output is as shown below;

[email protected]:~/Python-3.11.1$ sudo update-alternatives --install /usr/bin/python3 python3 /usr/local/bin/python3.11 1 update-alternatives: using /usr/local/bin/python3.11 to provide /usr/bin/python3 (python3) in auto mode [email protected]:~/Python-3.11.1$ python3 --version Python 3.11.1

Step 4. Install Python Modules on Linux Mint

To install Python Modules, we will need to use PIP that is the Python Package Manager. Hence the need to install Python PIP on our system. To do so, utilize the command below, then proceed to check the version installed;

sudo apt install python3-pip pip3 --version

An output of one of the commands above results in the following;

[email protected]:~/Python-3.11.1$ pip3 --version pip 22.3.1 from /usr/local/lib/python3.11/site-packages/pip (python 3.11)

From the above output PIP is successfully installed and we can then proceed to the next step, that is using PIP to install Python Modules. Utilize the command that follows if you want a Python module installed on your system;

Ensure to replace with the name of the module you want to install where ModuleName is. For example in case you want to install the flask module, you will utilize the command below;

python3 -m pip install flask
[email protected]:~/Python-3.11.1$ python3 -m pip install flask Defaulting to user installation because normal site-packages is not writeable Collecting flask Downloading Flask-2.2.2-py3-none-any.whl (101 kB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 101.5/101.5 kB 3.6 MB/s eta 0:00:00 Collecting Werkzeug>=2.2.2 Downloading Werkzeug-2.2.2-py3-none-any.whl (232 kB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 232.7/232.7 kB 7.4 MB/s eta 0:00:00 Collecting Jinja2>=3.0 Downloading Jinja2-3.1.2-py3-none-any.whl (133 kB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 133.1/133.1 kB 7.0 MB/s eta 0:00:00 Collecting itsdangerous>=2.0 Downloading itsdangerous-2.1.2-py3-none-any.whl (15 kB) Collecting click>=8.0 Downloading click-8.1.3-py3-none-any.whl (96 kB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 96.6/96.6 kB 9.0 MB/s eta 0:00:00 Collecting MarkupSafe>=2.0 Downloading MarkupSafe-2.1.1.tar.gz (18 kB) Preparing metadata (setup.py) . done Building wheels for collected packages: MarkupSafe Building wheel for MarkupSafe (setup.py) . done Created wheel for MarkupSafe: filename=MarkupSafe-2.1.1-cp311-cp311-linux_x86_64.whl size=28376 sha256=65be3a0a905582575acd6c07776b10bf602ed1de295d7891c44f4d8d621459cc Stored in directory: /home/val/.cache/pip/wheels/96/ee/62/407c247ad088bcb67b530ba3ac1479058c58a651bd6bf09a1f Successfully built MarkupSafe Installing collected packages: MarkupSafe, itsdangerous, click, Werkzeug, Jinja2, flask Successfully installed Jinja2-3.1.2 MarkupSafe-2.1.1 Werkzeug-2.2.2 click-8.1.3 flask-2.2.2 itsdangerous-2.1.2

To install a module specific to a certain user, run the command such as the one below, but be sure to replace user with the name of the user you are targeting as well as ModuleName with the specific name of the module;

python3 -m pip install --user ModuleName>

In order to upgrade a module, say for example we want to upgrade flask, we will run the command such as the one below;

python3 -m pip install --upgrade flask

You can as well uninstall a module using the command;

Читайте также:  Linux show device tree

So, to uninstall flask, we will utilize the command below;

python3 -m pip uninstall flask

Step 5. Open and Use Python

In order to use Python, we ought to launch it first. To open it, use the command shown below;

The output below shows how we opened Python by running the command. The second part of the output shows how Python can be utilized in calculations, and the third part used to give an output of a statement, check below;

[email protected]:~/Python-3.11.1$ python3.11 Python 3.11.1 (main, Dec 21 2022, 12:32:22) [GCC 11.3.0] on linux Type "help", "copyright", "credits" or "license" for more information. >>> 3*7 21 >>> 20+22 42 >>> 11+2*8 27 >>> print("Hello, World!") Hello, World! >>>

Conclusion

Источник

How to Install Latest Python on Linux Mint 21

Python is a user-friendly high-level and object-oriented programming language that can be easily interpreted. This general-purpose language is famous among users for simple coding projects to complex scripts including Artificial Intelligence and machine learning scripts. It has easily understandable syntax for coding even for the beginners.

Although it is easy to understand, it can perform complex algorithms and can handle huge amounts of data. Python language was designed in a way that it can be extended by adding more modules to the existing ones.

How to Install Latest Python on Linux Mint 21

The latest version of Python can be installed via an external PPA repository. For this, few steps should be followed carefully:

Open the terminal and update apt packages using command:

Execute the mentioned command to install prerequisite dependencies of Python:

Читайте также:  Вторичный dns сервер linux

Next step it to add PPA repository to the Linux Mint base repository (as it is external repository, so we need to add it first):

As all the dependencies and external repository are installed on Linux Mint 21. Now we can download Python on system by running the following command:

Use the version command to verify if python is installed or not:

How to Uninstall Python from Linux Mint 21

To remove Python from Linux Mint 21 system, the following would be use:

As we have added a PPA repository to the system before downloading Python. So, you can also remove it from system:

Conclusion

This article has focused on how to install an updated version of Python on Linux Mint 21. Python is a highly recommended interpreted language used for various purposes. It can create small projects to large scripts like machine learning and AI with understandable syntax. It was designed in a way that it can be extended by adding more modules to the existing ones.

About the author

Syeda Wardah Batool

I am a Software Engineer Graduate and Self Motivated Linux writer. I also love to read latest Linux books. Moreover, in my free time, i love to read books on Personal development.

Источник

Как обновить Python в Linux?

Как обновить Python в Linux?

Руководство по обновлению Python в операционных системах семейства Linux.

Введение

Представь себе ситуацию, ты придумал какой-нибудь проект, решил реализовать его на Python, открываешь терминал и обнаруживаешь старую версию, например Python 3.4.

Правильно, обновить Python через пакетный менеджер.

Далее я расскажу как это сделать.

Не забываем самое главное.

Все команды необходимо выполнять под пользователем root или же через sudo.

Обновление Python

Рассмотрим несколько примеров обновления Python в самых популярных дистрибутивах

Обновление Python в Debian Linux (Ubuntu, Raspbian, Mint и другие)

В моем случае я буду использовать raspberrypi 4 с дистрибутивом raspbian (основан на Debian buster). Открываем терминал (или подключаемся по ssh) и вводим команду apt update

Обновление python в дистрибутивах основанных на Debian (Ubuntu и др)

Видим примерно такую же ситуацию, локальный репозиторий обновил информацию о доступным пакетах из сетевого репозитория и стали доступны обновления других пакетов. Но мы сейчас не об этом. Нас интересует только python.

Как обновить Python в Linux?

В моем дистрибутиве используется последняя доступная версия 3.7.3-1

Обновление Python в Red Hat Linux (CentOS и Fedora Linux)

В принципе обновление пакетов в linux имеет схожий алгоритм. Сперва вы получаете список доступных пакетов из удаленного репозитория и сравнивание с тем, что установлено у вас локально. После обновление локального репозитория нужно инициализировать установку python. Разнообразных дистрибутивов linux у меня под рукой нет, да и используя я в серверных вариантах только debian-based. Но информация о работе с другими пакетными менеджерами доступна онлайн:)

Обновление python выполняется одной командой

Заключение

В этом руководстве мы узнали как обновить Python в Linux.

Источник

Оцените статью
Adblock
detector