Python install windows terminal

Установка Python на Windows, Linux, Mac OS

В данной статье мы рассмотрим, как устанавливать Python на Windows 10, Linux или mac OS по шагам.

Установка на Windows

Шаг 1 Для начала, нам понадобится скачать дистрибутив. Он находится на официальном сайте www.python.org в разделе » Downloads «.

Если вам нужна более ранняя версия Python, выберите пункт » Windows » слева в разделе » Downloads «.

Использовать версию ниже 2.x не рекомендуется — поддержка 2-й версии Python прекратилась в 2020 году

В списке также присутствуют версии Python 64-bit. 64-разрядная версия позволит одному процессу использовать больше оперативной памяти, чем 32-разрядная. Однако есть одна особенность: для хранения некоторых данных (например целых чисел) может потребоваться больше оперативной памяти, чем в версии 32-bit.

Если в ближайшее время вы не планируете заниматься научными вычислениями и задачами, в которых требуется более 2 ГБ памяти, используйте рекомендованную 32-битную версию.

Поставьте галочку около » Add Python 3.x to PATH «. Она отвечает за добавление пути до Python в системную переменной PATH (для того, чтобы запускать интерпретатор командой python без указания полного пути до исполняемого файла).

Далее выбираем » Install Now «.

После установки, отобразится сообщение «Setup was successful». Python установлен! 🎉

Шаг 3 Проверим, правильно ли всё установилось. В меню » Пуск » появилась папка » Python 3.x «. В ней мы видим IDLE (редактор кода), интерпретатор Python и документация.

Зайдем в командную строку Windows » WIN + R «. Вводим в поле » cmd » и нажимаем » ok «.

Набрав в консоли команду python —version мы увидим установленную версию Python.

Установка на Linux (из репозитория)

Python входит в состав большинства современных дистрибутивов Linux. Чтобы проверить, какая версия установлена в вашей системе, попробуйте выполнить следующие команды:

python —version python3 —version

Команды две, потому что в вашей системе могут быть установлены одновременно 2 версии — Python 2.x и Python 3.x.

Если python 3 не установлен, или необходимо обновить старую версию, для разных дистрибутивов Linux это делается по-разному. Для начала необходимо выяснить, какая версия дистрибутива установлена на вашей системе. Команда lsb_release -a покажет нужную информацию.

Читайте также:  Найти совершенное число python

Теперь вы знаете название и версию своего дистрибутива Linux и можете приступить к установке Python.

Ubuntu

Для установки Python 3.7 на Ubuntu, выполните следующие команды:

sudo apt-get update sudo apt-get install python3.7

Если вы используете старую версию Ubuntu, то пакета python3.7 может не быть в репозитории Universe. Вам нужно получить его из архива PPA (Personal Package Archive). Выполните следующие команды:

sudo apt install software-properties-common sudo add-apt-repository ppa:deadsnakes/ppa sudo apt-get update sudo apt-get install python3.7

Python 3.8 отсутствует в репозитории Ubuntu по умолчанию. Если выполнить команду sudo apt-get install python3.8 в консоли можно увидеть предупреждение Unable to locate package python3.8 .

Для установки Python3.8 выполните следующие команды:

sudo apt install software-properties-common sudo add-apt-repository ppa:deadsnakes/ppa sudo apt-get update sudo apt-get install python3.8

Debian

Первый способ, установка Python 3.7 с помощью команды:

Если данный способ не сработал, или отобразилась ошибка Unable to locate package python3.7 , есть второй способ — установка Python из исходников. Этот способ описан ниже.

Cent OS

Установить Python 3.6 можно следующим командами:

sudo yum install centos-release-scl sudo yum install rh-python36

Чтобы использовать установленную версию Питона, достаточно выполнить команду:

scl enable rh-python36 bash

Команда scl вызывает скрипт /opt/rh/rh-python36/enable, который меняет переменные окружения shell.

Обратите внимание — если вы выйдете из сеанса или откроете новый в терминале, версия по умолчанию будет 2.7.x., и команду scl нужно будет выполнять заново.

Для установки более свежей версии Python (например 3.8) воспользуйтесь установкой из исходников, описанной ниже.

Установка на Linux (из исходников)

Установка через исходники не так сложна, как кажется изначально. Она состоит из 4 шагов.

Шаг 1 Прежде чем начать устанавливать Python 3.8, необходимо установить необходимые библиотеки для компиляции Python следующими командами:

apt-get install build-essential checkinstall apt-get install libreadline-gplv2-dev libncursesw5-dev libssl-dev \ libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev libffi-dev zlib1g-dev

Шаг 2 Скачать архив Python 3.8 в любое место (например в /opt):

cd /opt wget https://www.python.org/ftp/python/3.8.1/Python-3.8.1.tgz

Доступные версии можно выбрать тут .

Разархивируем скачанный архив:

Шаг 3 Осталось скомпилировать исходники. Для этого выполним команды:

cd Python-3.8.1 ./configure —enable-optimizations make altinstall

altinstall используется для предотвращения замены бинарного файла python в папке /usr/bin

Шаг 4 Проверить установку можно командой:

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

Установка на MacOS

Для установки на Mac OS X, просто скачайте Python 3 с официального сайта www.python.org. Далее кликните на скачанный файл два раза, пройдите процесс установки и проверьте в консоли версию Python запустив команду python3 —version

Читайте также:  Среда программирования python windows

Альтернативный вариант — установка через Homebrew.

Шаг 1 Сначала необходимо установить сам Homebrew (если он отсутствует). Откройте приложение » Terminal » и выполните команду:

/bin/bash -c «$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)»

Проверим успешность установки командой brew doctor

И проверим результат установки:

Источник

2 Ways to install latest Python on Windows 11 or 10 – GUI & CMD

Installing Python 3 on Windows 11 or 10 machines is not difficult, however, if you are a beginner then we have discussed the both Graphical and command prompt ways to install it. Especially, for those who are not much familiar with Python, it is an open-source high-level interpreted programming language.

It is known for its versatility because it has been used widely for programming applications, web development, data analysis, machine learning, artificial intelligence, data visualization, web scraping, and scientific computing. The reason behind’s Python popularity among the developer community is its clear syntax, readability, ease of use, and large number of libraries & frameworks. All this is possible because of a vast but active community.

Python also supports most of the popular IDEs or can be written using a simple text file created using Notepad.

Let’s go through the article, whether you are a beginner or experienced, in this tutorial we will find the necessary steps required to install and set up Python on Windows operating systems.

Installing Python 3 on Windows 10 or 11

Here we are discussing two ways to set up Python one is using the graphical installation wizard and the other with the help of a command in prompt or Powershell (Terminal).

1. Download Python’s latest version

As we know Python is not included in Windows by default to compile our programs based on it. Therefore, visit the official website- python.org to download the latest version by clicking on the Download button.

Download Python for windows

2. Start Python Installation on Windows

After following the previous steps, you would already have the executable file of python on your Windows.

  • Double-click python executable to start the installation wizard.
  • Select the “Add Python.exe to PATH” box otherwise, we won’t be able to run PIP or Python using native Windows Powershell or command prompt.
  • After that click on the Install Now option.

Add python.exe to path

  • The setup will start running, this will also install PIP and documentation on your system.

Installing PIP pacakge manager

  • Finish the installation by clicking on the Close button.
Читайте также:  What is generator object python

Python installaion is done

3. Check version

To confirm, the installation is successful without any error, let’s check the version of installed Python and PIP. For this, you can either use the Command prompt or Powershell. Alternatively, we can also run the Python terminal app to issue commands, for that in your Windows Search type – python as its app appears, and click to open it. You will have a Python interpreter with version details as well.

Note: If typing python on on command terminal or Powershell, opens the Microsoft Store then go through the next step.

Check version

4. Stop Python from opening the Microsoft store

By default, if you type python on the command prompt or PowerShell in Windows, it will open Microsoft Store to download another version of Python instead of using the existing version of your Python. To stop that and tell the system to run the one you have installed, Follow the steps:

Stop Python from opening the Microsoft store

  1. Go to the Windows Search box
  2. Type- Manage App Execution Aliases
  3. As its icon appears click to open it.
  4. Search for Python3 and Python App Installers
  5. Turn off the toggle button given there for them.
  6. Close your CMD Terminal or Powershell and reopen it again.
  7. Now, type python in that to check your current version.

#Use the command line method

5. Open PowerShell, CMD, or Terminal (Admin)

Right-click on the Windows Start button and select Terminal (Admin). If you have PowerShell then you can go for that as well.

Open Windows Terminal

6. List Python versions

When you go for command line installation there are multiple versions available to install. We can use Winget to first check what are those and, later, to install them as well.

winget search Python.Python

winget command to search python

7. Use Winget to install Python

Once you have decided which version is suitable for your project then set it up using the following syntax.

winget install Python.Python.version-number

For example, if you want to have 3.11 then the command will be like this:

winget install Python.Python.3.11

When you are done with it, close your CMD terminal or PowerShell and reopen it again to check, whether it is working or not.

For that either use:

8. Run a simple program

Open the Python command line and type:

print ('Hey I am here with Python')

The above code will print “Hey I am here with Python” on your screen.

Run a simple program

Other Articles:

Источник

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