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
Problem Description In the recent background serv...
Let’s take a look at what kind of charging animat...
Checkboxes are very common on web pages. Whether ...
1 Background JDK1.8-u181 and Tomcat8.5.53 were in...
After installing wamp for the first time, all ser...
The pop-up has nothing to do with whether your cur...
<br />We have always emphasized semantics in...
When the front-end requests the interface, it is ...
1. Development environment vue 2. Computer system...
Preface lvm (Logical Volume Manager) logical volu...
This article uses examples to explain the knowled...
BinLog BinLog is a binary log that records all da...
This article shares the specific code for Vue to ...
1. Differences between JSON.stringify() and JSON....
Preface In front-end programming, we often use th...