Как обновить python debian

Обновлено: 06.07.2024

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

Статьи

Подробно рассмотрим как правильно обновить язык программирования Python.

Введение

Узнаем текущую версию

Командная строка Windows

Командная строка Windows

Скачиваем последнюю версию

Нажимаем кнопочку Download Python и скачиваем дистрибутив

Загрузка последней версии Python с помощью браузера Edge

Установка

Так как у меня установлена уже последняя версия Python мне пришлось скачать beta версию для демонстрации процесса обновления. Не пугайтесь из за того, что на картинках другая версия, это не ошибка 🙂

Запуск установочного пакета Python 3.9

Запуск установочного пакета Python 3.9

Ставим обязательно галочку перед пунктом Add Python 3.9 to PATH.

Нажимаем Install Now и переходим далее.

Обязательно предоставляем полные права приложению

Запрос прав администратора для установки Python

Запрос прав администратора для установки Python

Дожидаемся окончания процесса установки и в конце нажимаем Close

Завершение установки Python для Windows

Завершение установки Python для Windows

Проверка установки

В самом начале я описал процесс сверки текущий версии Python. Нам сейчас это необходимо повторить, только предварительно перезапустив окно cmd.exe иначе запуститься python старой версии 🙂

Заключение

В этой статье мы рассмотрели процесс обновления языка программирования Python, прошли от первого до последнего шага и успешно завершили обновление.

На это все. Поздравляю, теперь у вас установлена последняя версия Python.

Мне нужно установить последнюю версию Python на Debian. Уже изменил репозитории в sources.list на тестовые и обновился, но все равно не последняя версия Python. Обновлять всю систему с нестабильных или экспериментальных репозиториев не хочу.

Можно ли как-то из них установить только Python, либо установить из архива с официального сайта?


27.3k 10 10 золотых знаков 47 47 серебряных знаков 108 108 бронзовых знаков Вам обязательно менять "системный" Python или все-таки достаточно поставить локально? Очень рекомендую поставить "локально" Anaconda и обновляться, используя встроенный в нее менеджер пакетов - conda А я посоветую pyenv, с её помощью можно легко ставить разные версии Python и она не такая огромная как Anaconda. Если вы не пишите приложение, которое будет включено в официальные репозитории Debian, то системная версия Питона особо вас не должна интересовать. Существует множество способов запустить самую последнюю версию Питона (руками скомпилировать (несложно на Debian), запустить инструменты типа pyenv, pythonz, которые автоматически ск.или бинарные сборки типа anaconda поставить (если хочется и на Windows и на Debian похожие команды использовать), можно готовый deb поискать/самому собрать/docker запустить—вариантов полно (зависит какие у вас требования).

Нет пакета - можно собрать из исходников.

Рассмотрим глобальную установку с нуля (без обсуждения таких утилит как pyenv), для гольной Debian 8. Вам потребуется sudo :

Потребуется обновить список репозиториев с пакетами. Пример списка для версии, отличной от 8 можно взять отсюда. Нужно открыть файл /etc/apt/sources.list в любом текстовом редакторе ( sudo vi /etc/apt/sources.list ) и добавить для jessie:

Затем sudo apt-get update - обновит список пакетов.

Потребуется компилятор для C из пакета GNU Compiler Collection: gcc и make . Оба пакета есть в build-essential

Еще есть необязательные, но важные зависимости: zlib и ssl

Последняя зависимость - checkinstall - sudo apt-get install checkinstall .

Затем выбираем любую папку и в ней будет собираться Python 3.6. Для другой версии, необходимо будет поменять ссылку и имя файла на соответствующую версию. Пояснения по configure --enable-optimizations есть в README.

Аргумент -j4 разрешит параллельную компиляцию на 4 ядрах - можно указать любое доступное системе количество и это значительно ускорит сборку.

checkinstall вместо копирования в папки напрямую создаст .deb пакет и затем установит его. Основное преимущество - потом его (пакет) очень легко удалить. В противном случае нужно знать что и куда было установлено, чтобы удалить все вручную. Во время выполнения последней команды вам будет предложено настроить пакет - шаг можно пропустить и оставить все значения по-умолчанию. Аргумент pkgname не должен конфликтовать с существующими пакетами.

altinstall параметр не перезапишет версию python3 по-умолчанию (системные и не только утилиты могут ее использовать), а создаст только pythonX.X бинарник.

I'm running Ubuntu 9:10 and a package called M2Crypto is installed (version is 0.19.1). I need to download, build and install the latest version of the M2Crypto package (0.20.2).

The 0.19.1 package has files in a number of locations including (/usr/share/pyshared and /usr/lib/pymodules.python2.6).

How can I completely uninstall version 0.19.1 from my system before installing 0.20.2?


5,123 3 3 gold badges 28 28 silver badges 62 62 bronze badges 2,899 2 2 gold badges 13 13 silver badges 5 5 bronze badges

12 Answers 12

The best way I've found is to run this command from terminal

sudo will ask to enter your root password to confirm the action.

Note: Some users may have pip3 installed instead. In that case, use


576 1 1 gold badge 4 4 silver badges 17 17 bronze badges 5,839 2 2 gold badges 13 13 silver badges 13 13 bronze badges And if you are using a proxy without authentication: sudo pip install [package] --upgrade --proxy=address:port

You might want to look into a Python package manager like pip. If you don't want to use a Python package manager, you should be able to download M2Crypto and build/compile/install over the old installation.


177 1 1 gold badge 2 2 silver badges 11 11 bronze badges Thanks. What you said worked. I built and installed 0.20.2 without needing to uninstall 0.19.1.

To automatically upgrade all the outdated packages (that were installed using pip), just run the script bellow,

Here, pip list --outdated will list all the out dated packages and then we pipe it to awk, so it will print only the names. Then, the $(. ) will make it a variable and then, everything is done auto matically. Make sure you have the permissions. (Just put sudo before pip if you're confused) I would write a script named, pip-upgrade The code is bellow,

Then use the following lines of script to prepare it:

Then, just hit pip-upgrade and voila!

i got a syntax error pointing to the last bracket in: awk: cmd. line:1: < print $1 >) @TT Newer versions of pip require you to use the --format=legacy option, i.e., pip list --outdated --format=legacy . Also FYI everyone: blindly updating all modules via pip can be quite dangerous on many Linux distros. Many of them provide specific python modules via distro packages and some of those distros (RHEL in particular) can break hard if you updating shit . not to mention the fact that if you update via pip, the distro packages might revert your changes on a future update.
  1. Via windows command prompt, run: pip list --outdated You will get the list of outdated packages.
  2. Run: pip install [package] --upgrade It will upgrade the [package] and uninstall the previous version.

Again, this will uninstall the previous version of pip and will install the latest version of pip.


14.5k 2 2 gold badges 30 30 silver badges 62 62 bronze badges


  • Method 1: Upgrade manually one by one
  • Method 2: Upgrade all at once (high chance rollback if some package fail to upgrade
  • Method 3: Upgrade one by one using loop


211k 15 15 gold badges 103 103 silver badges 172 172 bronze badges

I think the best one-liner is:


Open Command prompt or terminal and use below syntax

How was the package originally installed? If it was via apt, you could just be able to do apt-get remove python-m2crypto

If you installed it via easy_install, I'm pretty sure the only way is to just trash the files under lib, shared, etc..

My recommendation in the future? Use something like pip to install your packages. Furthermore, you could look up into something called virtualenv so your packages are stored on a per-environment basis, rather than solely on root.

With pip, it's pretty easy:

But you can also install from git, svn, etc repos with the right address. This is all explained in the pip documentation

14.2k 1 1 gold badge 54 54 silver badges 64 64 bronze badges


211k 15 15 gold badges 103 103 silver badges 172 172 bronze badges


You should improve your answer by adding an explanation. Especially it needs clarification, how this differs from already given answers.

In Juptyer notebook, a very simple way is

So, you just need to replace with the actual package name.

Get all the outdated packages and create a batch file with the following commands pip install xxx --upgrade for each outdated packages

How can I completely uninstall version 0.19.1 from my system before installing 0.20.2?

In order to uninstall M2Crypto use

I need to download, build and install the latest version of the M2Crypto package (0.20.2).

In order to install the latest version, one can use PyPi

To install the version 20.2 (an outdated one), run

Assuming one just wants to upgrade

Depending on one's Python version (here's how to find the version) one may use a different pip command. Let's say one is working with Python 3.7, instead of just using pip , one might use pip3.7 .

Using sudo is considered unsafe.

Nowadays there are better practices to manage the development system, such as: virtual environments or development containers. The development containers allow one to put the entire development environment (be it modules, VS Code extensions, npm libraries. ) inside a Docker container. When the project comes to an end, one closes the container. There's no need to keep all of those requirements around in the computer for no reason. If you feel like reading more about it: Visual Studio Docs, Github.


I have covered this a number of times in the past and the posts have proved popular and useful to many. So, here is my guide for updating to the latest version of Python 3 (3.9) on Debian 10 Buster.

The basic premise is, install the version of python 3 desire, 3.9, then configure Debian to use python 3.7 at a higher priority to python 3.9.

This guide is written to target those using Debian 10, but the same principles apply to older versions of Debian and other operating system based on Debian, such as Kali Linux.

The Debian 10, Python upgrade process

Check your version
Step 1 is to check your current python version:

Download the latest or desired version of python 3
Next, we need to download the latest version or desired version of python 3 from the python website. In my case, I selected 3.9.1. Once downloaded we need to extract the tar file.

Make and Install
Now that we have the files downloaded and extracted, it is time to compile them.

Switch to the new Python version

Finally, after compiling the new version of python from source, we can now configure Debian to make it our default version of python3.

The integer at the end of this command (10) sets the priority for the python version; the greater the integer, the higher the priority. At this point, we can rerun the previously used version commands and we should see that we now have Python 3.9.1 active.

Fixing and Updating Pip

It was at this point that I attempted to install some required addons using pip and discovered that the upgrade to Python 3.9.1 had broken a few things. These were the commands I used to resolve issues with lsb_release and pip:

If you have found this guide useful or it has solved a burning issue for you, please consider throw a coin in the tip jar to help this site stay active:

Читайте также: