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.
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:
|
<<: Detailed explanation of how to use Vue self-nested tree components
>>: Introduction to MySQL triggers, creation of triggers and analysis of usage restrictions
Route Jump this.$router.push('/course'); ...
This article does not have any quibbles, it is jus...
Preface In fact, I have never encountered this ki...
Table of contents Problem description: Solution 1...
I saw in the LOFTER competition that it was mentio...
Mysqldump is used for logical backup in MySQL. Al...
Preface Many web applications store data in a rel...
Question: After the computer restarts, the mysql ...
Preface: This article is based on the experience ...
Table of contents 1. Map method 2. Application ba...
1. Use data from table A to update the content of...
Passive Check With passive health checks, NGINX a...
Table of contents Business Background Using Techn...
Table of contents 1. Description 2. Download rela...
Table of contents 1. props/$emit Introduction Cod...