In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)05/31 Report--
Today, I would like to share with you how to use the shell script to install the python3.8 environment in CentOS7. The content is detailed and the logic is clear. I believe most people still know too much about this knowledge, so share this article for your reference. I hope you can get something after reading this article.
One-click execution
Install the python3.8 environment with one click on the virtual machine, simply change the network adapter to nat mode (make sure the host has access to the Internet), then put the tar package in the / root directory and execute the script.
The script first uninstalls the original python2.7 environment of the system, then automatically changes the way of obtaining the address of the network card to dhcp, checks the network connectivity, changes the domestic yum source, then installs the python3.8 environment, finally installs python3.8, and prompts for friendly output after the installation is completed.
Download and share the tar package directly, including the python3.8 version of the tar package and script files.
Links: scripts and their tar packages
Extraction code: 4b6w
Content of the script:
#! / bin/bash
Echo "put the tar package of python under / root/ directory when using it"
Read-p "this script needs to be networked, if it is a virtual machine, please change the network adapter to nat mode"-T2
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 "obtained ip address successfully, address is $ip"
Else
Echo "failed to get the address, please check the network situation for yourself"
Exit 1
Fi
Ping-c 3 www.baidu.com & > / dev/null
If [$?-eq 0]; then
Echo "Network connection successful, start execution of 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 "successfully built domestic Yum source and is starting to install python environment"
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 complete, configuring python3.8"
Else
Echo "Environment installation error, please check that 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 complete, located at / usr/local/python_3.8"
Execution effect:
Note: the following is the effect of connecting the terminal. If executed in the virtual machine, the Chinese will be displayed as a small white box, but it will not affect its operation.
[root@test2 ~] # sh python3.8_install.sh
Put the tar package of python into the / root/ directory when using it.
This script needs to be networked. If it is a virtual machine, please change the network adapter to nat mode
Ip address obtained successfully, address is 192.168.125.130
The network connection is successful, start to execute the subsequent code
The domestic Yum source has been successfully built, and the installation of python environment is under way.
Environment installation complete, configuring python3.8
Python3.8 installation completed, located at / usr/local/python_3.8
After the installation is complete, the test uses
[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 exit
These are all the contents of the article "how to install the python3.8 environment using shell scripts in CentOS7". Thank you for reading! I believe you will gain a lot after reading this article. The editor will update different knowledge for you every day. If you want to learn more knowledge, please pay attention to the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.