Install Python3 and ansible under CentOS8

Compile and install Python3

First install some dependency packages required for compilation through yum:

[ root@localhost ~]# yum install -y wget gcc make libffi-devel zlib*

Enter the download address of Python official website:

https://www.python.org/downloads/source/

I chose the latest version 3.8.0:

Click the corresponding version to jump to the download page of that version, scroll to the bottom of the page, and copy the source code download link:

Then use the wget command to download on Linux, and use the tar command to decompress the downloaded source package:

[ root@localhost ~]# cd /usr/local/src
[ root@localhost /usr/local/src]# wget https://www.python.org/ftp/python/3.8.0/Python-3.8.0.tgz
[ root@localhost /usr/local/src]# tar -zxvf Python-3.8.0.tgz

Enter the decompressed directory and follow the steps below to complete the compilation and installation:

[ root@localhost /usr/local/src]# cd Python-3.8.0[root@localhost /usr/local/src/Python-3.8.0]# ./configure --prefix=/usr/local/python
[ root@localhost /usr/local/src/Python-3.8.0]# make && make install

After the installation is complete, you need to configure the system environment variables to use Python commands:

[ root@localhost ~]# vim /etc/profile
PYTHON_HOME=/usr/local/python
export PATH=$PATH:$PYTHON_HOME/bin
[ root@localhost ~]# source /etc/profile

Final verification version:

[ root@localhost /usr/local/src/Python-3.8.0]# pip3 --version
pip 19.3.1from/usr/local/python/lib/python3.8/site-packages/pip(python 3.8)[root@localhost /usr/local/src/Python-3.8.0]# python3
Python 3.8.0(default, Nov 202019,09:27:22)[GCC 8.2.120180905(Red Hat 8.2.1-3)] on linux
Type "help","copyright","credits" or "license"for more information.>>>exit()[root@localhost /usr/local/src/Python-3.8.0]# 

Install ansible via pip3

In CentOS7, you can install ansible directly through yum. However, the ansible installation package is no longer provided under the default yum source of CentOS8. Instead, you need to install it through Python's pip command, which is why you need to install Python first.

Before installing ansible, we need to change the source of pip, here is the source of Douban as an example. First execute the following command to install Douban source:

[ root@localhost ~]# pip3 install xlrd -i http://pypi.douban.com/simple --trusted-host pypi.douban.com

Then create a new pip configuration file in the user's home directory, the steps are as follows:

[ root@localhost ~]# mkdir ~/.pip  #New storage directory for configuration files
[ root@localhost ~]# vim ~/.pip/pip.conf  #Configure the download source as the source of Douban
[ global]
index-url = http://pypi.douban.com/simple
[ install]
trusted-host = pypi.douban.com
[ root@localhost ~]# 

After completing the replacement of the download source, you can start to install ansible. The installation command is as follows:

[ root@localhost ~]# pip3 install ansible

Finally, verify that the installation is successful:

[ root@localhost ~]# ansible --version
ansible 2.9.1
 config file = None
 configured module search path =['/root/.ansible/plugins/modules','/usr/share/ansible/plugins/modules']
 ansible python module location =/usr/local/python/lib/python3.8/site-packages/ansible
 executable location =/usr/local/python/bin/ansible
 python version =3.8.0(default, Nov 202019,09:27:22)[GCC 8.2.120180905(Red Hat 8.2.1-3)][root@localhost ~]#

Recommended Posts

Install Python3 and ansible under CentOS8
Install Python3 and Py under CentOS7
CentOS7 install python3 and pip3
CentOS 6.9 compile and install python
CentOS 6 compile and install python 3
Install and configure keepalived under CentOS 5.9
Centos7 install Python2.7
CentOS quickly install Python3 and pip3
Install and use docker under CentOS 6.8
Centos install Python3
CentOS6.8 install python2.7
Install Mono 3.2 and Jexus 5.4 under CentOS 6.3
Compile and install libmodbus library under CentOS7
Install Mono 2.10.8 and Jexus 5.0 under 32- and 64-bit CentOS 6.0
Install centos7 and connect
Install python3.6 under Ubuntu 16.04
Install mysql5.7 under CentOS7
Install ActiveMQ under Centos7
Install PostgreSQL12 under CentOS7
Install CentOS under VMware
Install mysql under Centos 7
Install MariaDB under MariaDB Centos7
Install mysql5.1 under CentOS6.5
Install svn and configuration through yum under CentOS
CentOs7.3 compile and install Nginx 1.9.9
Install python environment under Linux
CentOS 7 install Mono and MonoDevelop
ubuntu18.04 compile and install python3.8
Centos compile and install Git
Centos 6.10 reinstall python and yum
Install Oracle11gR2 database under CentOS6.9
Install MySQL under Linux (CentOS 7)
Centos6.5 install and configure mongodb
Install Java JDK8 under CentOS6
CentOS7 install OracleJDK and JRE
CentOS6.5 install Java 8 and Tomcat8
CentOS6 install and crack Jira 7
CentOS6.5 install Java 8 and Tomcat8
Centos7 compile and install ntp-4.2.8p11
Centos6 install python3 pip3 ipython3
CentOS6 install and crack confluence
Install MongoDB database under CentOS7
CentOS6 install and crack Jira 7
CentOS 6.8 under linux install mongodb
Install Mesos tutorial under CentOS7
Compile and install Lnmp shell script under Linux centos
Centos 7 install jdk and package service service
Install and use dig under ubuntu/debian
CentOS Yum compile and install MySQL 5.6
Use Nginx and u under CentOS
[Introduction to redis] Install redis under Centos
Upgrade OpenSSL and OpenSSH under CentOS7
CentOS + Python3.6+
CentOS 6.x compile and install Nginx
CentOS7 compile and install L(A|N)MP environment
CentOS7.3 install iptables and detailed use
Deploy and optimize Tomcat under Centos
How to install Python 3.8 on CentOS 8
CentOS7 yum install and start mysql
Install and deploy Gerrit under Ubuntu
CentOS 8 - install and configure NFS service