Перейти к содержимому

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

  • автор:

Как обновить python на сервере на windows

Необходимо установить django версии 4.1.3 на сервер, но проблема в том что на сервера по умолчанию версия питона 2.1.17 и максимальная версия django которую можно установить это 1.11.29, поэтому возникла необходимость установить новую версию python, однако я не понимаю как это сделать на windows. Я решил проверить есть ли debian подобие, ввел python3 —version. Выдало 3.6.9, однако я не понимаю как через него установить django, при использовании pip3 install django==4.1.3 выдает что pip3 нету. Поэтому мне нужно либо установить напрямую версию новую версию python, либо разобраться как мне установить django через версию 3.6.9

Отслеживать

48.6k 17 17 золотых знаков 56 56 серебряных знаков 100 100 бронзовых знаков

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

На одной рабочей машине одновременно может быть установлено несколько версий Python. Это бывает полезно, когда идет работа с некоторыми внешними библиотеками, которые поддерживают разные версии python, либо в силу каких-то других причин нам надо использовать несколько разных версий. Например, на момент написания статьи последней и актуальной является версия Python 3.11 . Но, допустим, необходимо также установить версию 3.10 , как в этом случае управлять отдельными версиями Python?

Windows

На странице загрузок https://www.python.org/downloads/ мы можем найти ссылку на нужную версию:

Управление несколькими версиями Python

И также загрузить ее и установить:

Установка разных версий Python на Windows

Чтобы при использовании интерпретатора Python не прописывать к нему весь путь, добавим при установке его в переменные среды. Но здесь надо учитывать, что в переменных среды может содержаться несколько путей к разным интерпретаторам Python:

Установка разных версий Python на Windows в переменные среды

Та версия Python, которая находится выше, будет версией по умолчанию. С помощью кнопки «Вверх» можно нужную нам версию переместить в начало, сделав версией по умолчанию. Например, в моем случае это версия 3.11. Соответственно, если я введу в терминале команду

python --version

или

py --version

то консоль отобразит версию 3.11:

C:\python>python --version Python 3.11.0

Для обращения к версии 3.10 (и всем другим версиям) необходимо использовать указывать номер версии:

C:\python>py -3.10 --version Python 3.10.9

например, выполнение скрипта hello.py с помощью версии 3.10:

py -3.10 hello.py

Подобным образом можно вызывать и другие версии Python.

MacOS

На MacOS можно установить разные версии, например, загрузив с официального сайта пакет установщика для определенной версии.

Для обращения к определенной версии Python на MacOS указываем явным образом подверсию в формате python3.[номер_подверсии] . Например, у меня установлена версия Python 3.10. Проверим ее версию:

python3.10 --version

Аналогично обращении к версии python3.9 (при условии если она установлена)

python3.9 --version

К примеру выполнение скрипта hello.py с помощью версии python 3.10:

python3.10 hello.py

Linux

На Linux также можно установить одновременно несколько версий Python. Например, установка версий 3.10 и 3.11:

sudo apt-get install python3.10 sudo apt-get install python3.11

Одна из версий является версий по умолчанию. И для обращения к ней достаточно прописать python3 , например, проверим версию по умолчанию:

python3 --version

Для обращения к другим версиям надо указывать подверсию:

python3.10 --version python3.11 --version

Например, выполнение скрипта hello с помощью версии Python 3.10:

python3.10 hello.py

Но может сложиться ситуация, когда нам надо изменить версию по умолчанию. В этом случае применяется команда update-alternatives для связывания определенной версии Python с командой python3. Например, мы хотим установить в качестве версии по умолчанию Python 3.11. В этом случае последовательно выполним следующие команды:

sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.10 1 sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.11 2

Числа справа указывают на приоритет/состояние. Так, для версии 3.11 указан больший приоритет, поэтому при обращении к python3 будет использоваться именно версия 3.11 (в моем случае это Python 3.11.0rc1)

Управление версиями Python в linux

С помощью команды

sudo update-alternatives --config python3

можно изменить версию по умолчанию

Как правильно обновить версию Python в Windows?

Нигде толком не описано как правильно обновлять Python. Как правильно? Просто снести через установку удаление и по новой установить? А как быть с пакетами?

UPD Ставить поверх

  • Вопрос задан более трёх лет назад
  • 19806 просмотров

Комментировать

Решения вопроса 0

Ответы на вопрос 1

AnnTHony

How to Update Python in Windows, Linux & MacOS

Every year Python launches a new version of itself to provide new and improved services to its users. With every update, Python launches new features and bug fixes. This article shows, How to update Python on different platforms?

A section of the article also shows how to check the current Python version installed in the system.

Check your Python version:

Before updating Python, one should check if one already has the latest version of Python in the system. Let us now follow the steps provided in the subsequent section for fetching the Python version.

For Windows

Open the command prompt to check the Python version installed:

  1. Click the Windows key and search cmd.
  2. Open the command prompt, type python, and hit enter.

Its version number shall appear after the phrase Python.

For MAC

Python comes pre-installed in the MAC operating system. If your computer has an old Python version, programmers can update it to the latest one following the process given here.

For checking the Python version present in the system:

  1. Open the application folder ->Utilities folder->open the terminal.
  2. Once you open the terminal window, type the given command, and click the return key to confirm the version of Python.
python --version 

The above command shall show the Python’s version number that is installed in your computer.

For Linux

Python comes pre-installed in the Linux operating system. Before updating, it is crucial to check the Python version installed in the system.

To check the Python version present in the system:

  1. Open the terminal window in Linux by simply clicking Ctrl + Alt + T
  2. Type the below command and hit the return key
python --version

This command will display the current Python version number installed in the system.

Updating the Python for various platforms (MAC, Windows, and Linux)

One can update Python by going to its official site and then downloading the latest version of Python available. One can also use the terminal or command prompt of the operating system to update Python.

Update Python in Windows

Updating Python is easy for Windows users.

  1. Go to the website of Python, and click on the Python download button
  2. After clicking the Python download button, downloading of the installation file shall begin
  3. Now run the installer, the installer will automatically suggest downloading the latest version of Python
  4. And, if the system has an old Python version, the installer will display an upgrade now button. Click the button to start the upgrading process.

Update Python in MAC Systems

One can update Python for MAC from Python's official website. One can also update Python in MAC using Homebrew. You have to follow the steps provided in the subsequent section to update Python with Homebrew:

First, one needs to have the Homebrew package manager in his system. To do that, one must download Homebrew from the Homebrew site. One can also download Homebrew by copying the below code into the terminal.

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"

Now to update Python, enter the below commands in the terminal:

brew upgrade python3 #(old Python version number)

Update Python in Linux Systems

If the system doesn't have the latest version of Python, one can update the Python by copying the below commands to the terminal:

sudo apt update sudo apt install software-properties-common

The above command will install all the essential packages required to install the latest version of Python.

Conclusion:

Every year Python launches a new version to provide new and improved services to its users. This article is about installing the latest and updated Python’s version. One can follow the above steps to check if Python's latest version is already present in the system. Knowing that will surely save a lot of time and effort.

Recommended Posts:

  • Python Training Tutorials for Beginners
  • Addition of two numbers in Python
  • TypeError: 'int' object is not subscriptable
  • Python Comment
  • Python Uppercase
  • Python map()
  • Python String Replace
  • Invalid literal for int() with base 10 in Python
  • Polymorphism in Python
  • Inheritance in Python
  • Python : end parameter in print()
  • Python String Concatenation
  • Python zip()
  • Install Opencv Python PIP Windows
  • String Index Out of Range Python
  • Reverse Words in a String Python
  • Area of Circle in Python
  • Bubble Sort in Python
  • indentationerror: unindent does not match any outer indentation level in Python
  • Python Return Outside Function

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

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