Under Linux, install python3 with one click; suitable for Centos, Debian, Ubuntu, etc.

888u

Last update at :2024-07-13,Edit by888u

1. Installation under Centos

wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo yum install python36 -y yum install python36-pip -y python3 --version

2. Applicable to various Linux systems

Save the following code as py3.py, and then execute python py3.py

Or execute directly:

wget https://bmvps.com/wp-content/uploads/2019/12/py3.py pythonpy3.py

Here is the code:

#coding=utf-8 import subprocess import os,sys def exe_cmd(cmd): p = subprocess.Popen(cmd, shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) while True: next_line = p.stdout.readline() return_line = next_line.decode("utf-8", "ignore") if return_line == '' and p.poll() != None: break print(return_line) stdout, stderr = p.communicate() if p.returncode != 0: return False return True def main(): print ("Python 3.7.2 one-click installation begins!") backinfo = exe_cmd('ping -c 1 -w 1 www.baidu.com') if backinfo == False: print ("Network detection failed and the program exited, please check the network environment again!") sys.exit() print ("Network connection is normal!") yum_jc = exe_cmd('yum list') if yum_jc == False: print ("yum is not available, please manually configure yum installation first!") sys.exit() print ('yum installation detection available!') exe_cmd("yum install gcc -y") exe_cmd("yum install openssl-devel bizp2-devel expat-devel gdbm-devel readline-devel sqlite-devel libffi-devel -y") exe_cmd("wget ​​http://npm.taobao.org/mirrors/python/3.7.2/Python-3.7.2.tgz") exe_cmd("tar -zxvf Python-3.7.2.tgz") exe_cmd("mv Python-3.7.2 /usr/local/") exe_cmd("rm -rf Python-3.7.2.tgz") os.chdir('/usr/local/Python-3.7.2') exe_cmd("./configure") exe_cmd("make") exe_cmd("make install") print ("Program execution completed! Enter python3 to see the effect.") if __name__ == '__main__': main()

Recommended site search: latest free proxy IP, vps host, domain name query, permanent free space, purchase of registered domain names, free IP addresses in mainland China, how to query IP addresses, registered domain names, Korean proxy IP, free servers,

Under Linux, install python3 with one click; suitable for Centos, Debian, Ubuntu, etc.

All copyrights belong to 888u unless special state
取消
微信二维码
微信二维码
支付宝二维码