root用戶權限
# vim install_python3.sh
1
#!/bin/sh
yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel libffi-devel
wget https://www.python.org/ftp/python/3.7.0/Python-3.7.0.tgz
tar -zxvf Python-3.7.0.tgz
mkdir /usr/local/python3
cd Python-3.7.0
./configure --prefix=/usr/local/python3
make make install
[ -f /usr/bin/python3 ] mv /usr/bin/python3 /usr/bin/python3_old
[ -f /usr/bin/pip3 ] mv /usr/bin/pip3 /usr/bin/pip3_old
ln -s /usr/local/python3/bin/python3.7 /usr/bin/python3
ln -s /usr/local/python3/bin/pip3.7 /usr/bin/pip3
ps:下面看下shell腳本--一鍵安裝python3+pip
安裝python3.6.1
#!/bin/bash
yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel epel-release gcc
wget https://www.python.org/ftp/python/3.6.1/Python-3.6.1.tgz
tar vxf Python-3.6.1.tgz
cd Python-3.6.1
./configure --prefix=/usr/local
make make install
cd ..
yum -y install python-pip
安裝python3.6.6
yum install zlib zlib-devel readline-devel sqlite-devel bzip2-devel openssl-devel gdbm-devel libdbi-devel ncurses-libs kernel-devel libxslt-devel libffi-devel python-devel zlib-devel openldap-devel sshpass gcc git -y
yum install http://www.percona.com/downloads/percona-release/redhat/0.1-6/percona-release-0.1-6.noarch.rpm -y
yum install Percona-Server-server-56 install Percona-Server-devel-56 -y
wget https://www.python.org/ftp/python/3.6.6/Python-3.6.6.tgz #CentOS 7不用安裝python2.7
tar -xzvf Python-3.6.6.tgz
cd Python-3.6.6
./configure --prefix=/usr/local/python3
make all
make install
make clean
make distclean
ln -s /usr/local/python3/bin/python3 /usr/bin/python3
ln -s /usr/local/python3/bin/pip3 /usr/bin/pip3
總結
以上所述是小編給大家介紹的shell自動安裝python3的腳本寫法,希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會及時回復大家的。在此也非常感謝大家對腳本之家網站的支持!
如果你覺得本文對你有幫助,歡迎轉載,煩請注明出處,謝謝!
您可能感興趣的文章:- CentOS7中使用shell腳本安裝python3.8環(huán)境(推薦)
- python shell命令行中import多層目錄下的模塊操作
- Python IDLE或shell中切換路徑的操作
- 使用python執(zhí)行shell腳本 并動態(tài)傳參 及subprocess的使用詳解
- 在python shell中運行python文件的實現(xiàn)
- python3模擬實現(xiàn)xshell遠程執(zhí)行l(wèi)iunx命令的方法
- Python3交互式shell ipython3安裝及使用詳解