Use shell script to install python3.8 environment in CentOS7 (recommended)

Use shell script to install python3.8 environment in CentOS7 (recommended)

One-click execution

To install Python 3.8 in a virtual machine, you only need to change the network adapter to NAT mode (make sure the host can access the Internet), then put the tar package in the /root directory and execute the script.

The script first uninstalls the system's original python2.7 environment, then automatically changes the way the network card obtains the address to dhcp, checks network connectivity, changes the domestic yum source, then installs the python3.8 environment, and finally installs python3.8. After the installation is complete, a friendly output is prompted.

Just download the shared tarball, which contains the python 3.8 version tarball and script files.

Link: Script and its tarball Extraction code: 4b6w

Script content:

#!/bin/bash
echo "Put the python tarball in the /root/directory when using it"
read -p "This script requires an Internet connection. If it is a virtual machine, please change the network adapter to NAT mode" -t 2
echo
sed -i "s/BOOTPROTO=static/BOOTPROTO=dhcp/" /etc/sysconfig/network-ifcfg-ens33
ifdown ens33
ifup ens33
systemctl start network &>/dev/null
systemctl restart network &>/dev/null
if [ $? -eq 0 ];then
ip=`ifconfig ens33 | awk 'NR==2 {print $2}'`
echo "Successfully obtained IP address, address is $ip"
else
echo "Failed to obtain address, please check the network status yourself"
exit 1
fi
ping -c 3 www.baidu.com &>/dev/null
if [ $? -eq 0 ];then
echo "Network connection successful, start executing subsequent code"
else
echo "Network connection failed, please check if the address is available"
exit 1
fi
cd /etc/yum.repos.d/
rm -rf *
wget http://mirrors.163.com/.help/CentOS7-Base-163.repo &>/dev/null
yum clean all &>/dev/null
yum makecache &>/dev/null
yum install gcc patch libffi-devel python-devel zlib-devel bzip2-dnssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-4-devel libpcap-devel xz-devel -y &>/dev/null
echo "The domestic yum source has been successfully built, and the Python environment is being installed"
cd /root/
tar zxf Python-3.8.0a2.tgz &>/dev/null
cd Python-3.8.0a2/
./configure --prefix=/usr/local/python_3.8 &>/dev/null
if [ $? -eq 0 ];then
echo "Environment installation completed, configuring python3.8"
else
echo "Environment installation error, please check whether all dependent packages are installed"
fi
make -j 4 &>/dev/null
make install &>/dev/null
ln -s /usr/local/python_3.8/bin/* /usr/bin/
echo "python3.8 installation completed, located in /usr/local/python_3.8"

Implementation effect:

Note: The following is the effect of connecting to the terminal. If executed in a virtual machine, Chinese characters will be displayed as small white boxes, but it will not affect its operation.

[root@test2 ~]# sh python3.8_install.sh
When using, put the python tarball in the /root/directory. This script requires an Internet connection. If it is a virtual machine, please change the network adapter to NAT mode. Successfully obtain the IP address, the address is 192.168.125.130
The network connection is successful, and the subsequent code is executed. The domestic yum source is successfully built, and the python environment is being installed. The environment installation is complete, and python3.8 is being configured.
Python 3.8 is installed and is located at /usr/local/python_3.8

After installation, test using

[root@test2 ~]# python3
Python 3.8.0a2 (default, Mar 29 2020, 19:45:00) 
[GCC 4.8.5 20150623 (Red Hat 4.8.5-16)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> print('hello')
hello
>>> #Ctrl+d to exit

Summarize

This is the end of this article about using shell scripts to install python3.8 environment in CentOS7. For more information about installing python3.8 environment in centos7, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope you will support 123WORDPRESS.COM in the future!

You may also be interested in:
  • Centos8 (minimum installation) tutorial on how to install Python3.8+pip
  • Install the latest python3.8 under Centos7
  • VirtualBox CentOS7.7.1908 Python3.8 build Scrapy development environment [graphic tutorial]
  • Detailed tutorial for installing python3.8.2 in CentOS

<<:  Detailed explanation of how to use Vue self-nested tree components

>>:  Introduction to MySQL triggers, creation of triggers and analysis of usage restrictions

Recommend

How to automatically number the results of MYSQL query data

Preface In fact, I have never encountered this ki...

Solution to the problem of repeated triggering of functions in Vue project watch

Table of contents Problem description: Solution 1...

Improvement experience and sharing of 163 mailbox login box interactive design

I saw in the LOFTER competition that it was mentio...

How to use mysqldump for full and point-in-time backups

Mysqldump is used for logical backup in MySQL. Al...

Memcached method for building cache server

Preface Many web applications store data in a rel...

How to solve the Docker container startup failure

Question: After the computer restarts, the mysql ...

Detailed tutorial on installing CUDA9.0 on Ubuntu16.04

Preface: This article is based on the experience ...

Application of mapState idea in vuex

Table of contents 1. Map method 2. Application ba...

Nginx http health check configuration process analysis

Passive Check With passive health checks, NGINX a...

Step by step guide to build a calendar component with React

Table of contents Business Background Using Techn...

Detailed explanation of how to use eslint in vue

Table of contents 1. Description 2. Download rela...

In-depth understanding of the seven communication methods of Vue components

Table of contents 1. props/$emit Introduction Cod...