- ИТ База знаний
- Полезно
- Навигация
- Серверные решения
- Телефония
- Корпоративные сети
- Установка Python в CentOS 8 и RHEL 8
- Установка Python 2
- Шаг 1. Обновление среды
- Шаг 2: Установите Python 2
- Шаг 3: Проверьте установку Python 2
- Шаг 4: Запуск Python 2
- Установка Python 3
- Шаг 1. Обновление среды
- Шаг 2: Установите Python 3
- Шаг 3: Проверьте установку Python 3
- Шаг 4: Запуск Python 3
- Установка версии Python по умолчанию
- RHEL 8 install Python 3 or Python 2 using yum
- How to Install Python 3 / Python 2.7 on RHEL 8
- How to find out Python package names on RHEL 8
- RHEL 8 install Python 3
- Build your first application using native Python on RHEL 6 or RHEL 7
- Introduction and Prerequisites
- 1. Prepare your system
- 2. Setup your development environment
- 3. Hello World and your first application
- Where to go next?
- Want to know more about what you can do with RHEL?
- Become a Red Hat developer: developers.redhat.com
- Troubleshooting and FAQ
- Install Python 3 on Linux (Redhat, CentOS, Ubuntu)
- Step 1.
- Step 2.
- Step 3.
- Step 4.
- Step 5.
- Troubleshooting Python issues
ИТ База знаний
Курс по Asterisk
Полезно
— Узнать IP — адрес компьютера в интернете
— Онлайн генератор устойчивых паролей
— Онлайн калькулятор подсетей
— Калькулятор инсталляции IP — АТС Asterisk
— Руководство администратора FreePBX на русском языке
— Руководство администратора Cisco UCM/CME на русском языке
— Руководство администратора по Linux/Unix
Навигация
Серверные решения
Телефония
FreePBX и Asterisk
Настройка программных телефонов
Корпоративные сети
Протоколы и стандарты
Установка Python в CentOS 8 и RHEL 8
4 минуты чтения
Python — один из самых популярных языков программирования. Однако в CentOS 8 он не установлен по-умолчанию.
Мини — курс по виртуализации
Знакомство с VMware vSphere 7 и технологией виртуализации в авторском мини — курсе от Михаила Якобсена
В более ранних выпусках CentOS по умолчанию была доступна неверсированная команда Python. После установки CentOS, можно было перейти в оболочку Python, просто запустив команду «python» в терминале. Как это ни парадоксально, CentOS 8 не имеет неверсионной команды Python по умолчанию. Напрашивается вопрос, почему? RedHat заявляет, что этот выбор сделан «чтобы избежать блокировки пользователей в конкретной версии Python». В настоящее время RedHat 8 неявно использует Python 3.6 по умолчанию, хотя Python 2.7 дополнительно предоставляется для поддержки существующего программного обеспечения. Ранее неверсионная команда Python в дистрибутивах CentOS, хотя и была удобной, создавала определенные проблемы. Неверсионный Python обычно указывает на интерпретатор Python 2, но поскольку Python 2 сейчас находится на EOL (конец срока службы), это становится проблематичным по нескольким причинам. Простое перенаправление команды на Python 3 может показаться несложным решением, но на многих уровнях это будет проблематично из-за возможной путаницы с версионированием. Вместо того, чтобы продолжать указывать команду «python» на версию Python по умолчанию из-за знакомства или указывать на Python 3, чтобы идти в ногу со временем, был сделан выбор больше не включать стандартную команду «python».
В этом руководстве мы рассмотрим установку как активно используемой версии Python 2, так и новой версии Python 3 в CentOS 8 и Red Hat Enterprise Linux (RHEL) 8.
Установка Python 2
Шаг 1. Обновление среды
Всегда полезно начинать с проверки того, что все наши системные пакеты обновлены перед установкой нового программного обеспечения. Для этого мы собираемся воспользоваться новым программным обеспечением для управления пакетами DNF.
Шаг 2: Установите Python 2
Теперь, когда среда обновлена, давайте продолжим и будем использовать DNF для установки Python 2. К счастью, и Python 2, и 3 включены в репозитории базовых пакетов CentOS 8, поэтому установка выполняется просто.
Шаг 3: Проверьте установку Python 2
Чтобы убедиться, что Python 2 установлен, мы можем запустить простую команду «python2» с флагом версии.
Шаг 4: Запуск Python 2
Впоследствии, чтобы получить доступ к оболочке Python 2, мы можем выполнить следующую команду.
Готово! Python 2 теперь установлен! Следует отметить, что PIP-установщик пакетов Python также устанавливается по умолчанию при установке Python 2, поэтому вы сможете сразу начать работу с пакетами Python.
Установка Python 3
Шаг 1. Обновление среды
Еще раз давайте убедимся, что наши системные пакеты обновлены.
Шаг 2: Установите Python 3
Теперь мы готовы установить Python 3.
Шаг 3: Проверьте установку Python 3
Мы можем проверить установку и версию Python 3 так же, как и в Python 2.
Шаг 4: Запуск Python 3
Затем мы можем войти в среду оболочки Python 3, выполнив следующую команду.
Как и в случае установки Python 2, pip3 также включается при установке Python 3. Вот и все! Теперь можно начинать работу с Python на вашем сервере CentOS 8.
Установка версии Python по умолчанию
Вы должны были заметить, что для использования Python 3, это команда python3 и python2 для Python 2. Что делать, если ваши приложения настроены на обращение к python, который недоступен для всей системы?
Вы можете использовать механизм альтернатив, чтобы включить неверсированную команду python для всей системы и установить для нее определенную версию:
Чтобы посмотреь настроенную версию Python по умолчанию используйте следующую команду:
Чтобы сбросить эту конфигурацию и удалить неверсионную команду python, выполните:
Мини — курс по виртуализации
Знакомство с VMware vSphere 7 и технологией виртуализации в авторском мини — курсе от Михаила Якобсена
Источник
RHEL 8 install Python 3 or Python 2 using yum
How to Install Python 3 / Python 2.7 on RHEL 8
The procedure for installing Python 3 on RHEL 8 is as follows:
- Open the Terminal application or window.
- Search for python package in RHEL 8, run: sudo yum search python3
- To install python 3 on RHEL 8, run: sudo yum install python3
- To install python 2 on RHEL 8, run: sudo yum install python2
- Upgrade python 3 in RHEL 8, run: sudo yum upgrade python3
- Upgrade python 2 in RHEL 8, run: sudo yum upgrade python2
Let us see all commands and example in details.
How to find out Python package names on RHEL 8
Try any one of the following syntax along with grep command:
sudo yum search python3 | more
sudo yum search python2 | more
sudo yum search python36
sudo yum search python2 | grep ‘python2.x86_64’
You can show detailed information before installing package as well:
sudo yum info python2.x86_6
sudo yum info python36
RHEL 8 install Python 3
Type the following yum command to install Python 3 on Red Hat Enterprise Linux version 8:
sudo yum install python3
OR
sudo yum module install python36
Verify installation by typing the type command/command command:
$ type -a python3
python3 is /usr/bin/python3
$ command -V python3
python3 is hashed (/usr/bin/python3)
$ python3 —version
Python 3.6.6
Источник
Build your first application using native Python on RHEL 6 or RHEL 7
Get started developing with Python on Red Hat Enterprise Linux in under 10 minutes.
Introduction and Prerequisites
In this tutorial, you will see how to get started with Python development on Red Hat Enterprise Linux by creating a simple Hello World application. The tutorial should take 5 to 10 minutes to complete.
On Red Hat Enterprise Linux, Python is installed by default. You can skip directly to Hello Word and your first application, or continue reading to learn more about installing and maintaining software packages.
Before you begin, you will need a current Red Hat Enterprise Linux 6 or 7 workstation or server subscription that allows you to download software and get updates from Red Hat. If you don’t have an active subscription, register and obtain the RHEL Developer Suite (includes RHEL server) from here.
The native version of Python are:
Red Hat Enterprise Linux 6 — 2.6
If you want a newer version of Python for either RHEL 6 or 7, use the updated versions available via Red Hat Software Collections.
If you have problems at any point, see Troubleshooting and FAQ.
1. Prepare your system
In this step, you will download and install the latest updates from Red Hat for your system. In the process, you will verify that your system has a current Red Hat subscription and is able to receive updates.
First, start a Terminal window from the Application menu. Then after using su to change to the root user ID, use subscription-manager to verify that you have access to Red Hat Software Repositories.
If you don’t see any enabled repositories, your system might not be registered with Red Hat or might not have a valid subscription. See Troubleshooting and FAQ for more information.
Now download and install any available updates by running yum update . If updates are available, yum will list them and ask if it is OK to proceed.
2. Setup your development environment
Python 2.7 and a number of popular Python modules are installed by default on Red Hat Enterprise Linux. To see what Python packages are already installed, run the following yum command after becoming root with su . If you don’t already have a Terminal window open, start one from the Applications menu.
If Python wasn’t installed or needed an update, you would only need to run one yum command.
# yum install python
To see what other Python modules are included with Red Hat Enterprise Linux, run this command:
# yum list available python\*
You are now done with the part that requires root privileges. Type exit to return to your normal user ID.
3. Hello World and your first application
In this step, you will first run Python in interactive mode. Then you will create a Python application that can be run from the command line. If you don’t have a Terminal window open, start it from the Applications menu. You should run under your normal user ID, If you are still running as root, type exit .
The next step is to create a Python application that can be run from the command line. Using your preferred text editor, create a file named hello.py :
Add the following text to the file:
Save it and exit the editor. Then make the script executable and run it:
Where to go next?
Python Tutorial at Python.org
https://docs.python.org/
Find additional Python modules
$ yum list available python\*
Want to know more about what you can do with RHEL?
Become a Red Hat developer: developers.redhat.com
Red Hat delivers the resources and ecosystem of experts to help you be more productive and build great solutions. Register for free at developers.redhat.com.
Follow the Red Hat Developer Blog
https://developers.redhat.com/blog/
Learn about Red Hat Software Collections
Red Hat Software Collections deliver the latest stable versions of dynamic languages, open source databases, and web development tools that can be deployed alongside those included in Red Hat Enterprise Linux. Red Hat Software Collections is available with select Red Hat Enterprise Linux subscriptions and has a three-year life cycle to allow rapid innovation without sacrificing stability.
Troubleshooting and FAQ
My system is unable to download updates from Red Hat.
I don’t have a current Red Hat subscription, can I get an evaluation?
If you don’t have a Red Hat Enterprise Linux subscription, you can try it for free. Get started with an evaluation at https://access.redhat.com/products/red-hat-enterprise-linux/evaluation. Developers should select the Red Hat Enterprise Linux Developer Workstation option to ensure your evaluation includes additional tools from the Red Hat Developer Toolset and Red Hat Software Collections.
Some Python code/examples I’ve tried don’t work with Python 2 from Red Hat Enterprise Linux.
Python 3.x is a new version of the Python language that is incompatible with the previous 2.x series. The version of Python included with Red Hat Enterprise Linux in /usr/bin/python is from the Python 2.x series. There is a large amount of code written for Python 2.x that will not run without modification on Python 3.x. Likewise, code that is written for Python 3 is incompatible with Python 2.
How can I get Python 3 on Red Hat Enterprise Linux?
Python 3 is available through Red Hat Software Collections, which delivers the latest stable versions of dynamic languages, open source databases, and web development tools that can be deployed alongside those included in Red Hat Enterprise Linux. Red Hat Software Collections is available with select Red Hat Enterprise Linux subscriptions and has a three-year life cycle to allow rapid innovation without sacrificing stability.
Last updated: November 19, 2020
Источник
Install Python 3 on Linux (Redhat, CentOS, Ubuntu)
Published: November 6, 2017 | Modified: June 25, 2020
Learn how to install python 3 on Linux like Redhat, centos, ubuntu, etc. Also, learn how to get rid of a few python related errors.
By default, all of the Linux distros have pre-installed Python. Most of it is Python 2.x. not Python 3.x. Many of nowadays tools, scripts, etc need Python version 3 ( python3 ) for compiling.
In this article, we will see how to install python3 step by step on Linux like RHEL, centos, ubuntu, etc.
If your package manager repo does offer python3 for install then you can easily install it from there,. If not then follow this process to install from source code.
Let’s get into the step by step Python installation from its source code. As of today, the Latest Python release is 3.6.3 and it’s available here.
Step 1.
Download source code from the Python website on your server using tools like wget. We are using the latest release link here.
Step 2.
Un-tar downloaded file and navigate to newly created Python directory Python-3.6.3 . Also, make sure you have a GCC package installed on your system. If not install package gcc before proceeding to the next step.
Step 3.
Now its time to compile the source code. Execute configure script in Python-3.6.3 directory.
Step 4.
Now run make followed by make install to complete the installation. Both commands output is not given here since its pretty long.
Step 5.
Check Python installed version from Python prompt.
You can see in the above output Python 3.6.3 shows we have installed python v3 successfully.
Troubleshooting Python issues
When using or compiling Python programs you might run into below errors. I have listed their solutions for your quick reference.
Error : ImportError: No module named ‘zlib’
Solution: Install zlib-devel (zlib development tools) package and re-install python
Error : ImportError: cannot import name ‘HTTPSConnection’
Solution: Install OpenSSL-devel (Open SSL development tools) package and re-install python
Error : zipimport.ZipImportError: can’t decompress data; zlib not available
Solution: This error is seen during Python installation if zlib is not installed on the server. Install zlib package
Источник