kali怎么安装python3_快捷安装不同版本Python

一、目的

日常测试中,为快捷在Linux系统下安装不同版本Python并安装pip。

二、脚本

#!/bin/bash

#mail:xuel@anchnet.com

#function:auto install python

sys_init() {

[ -f /etc/init.d/functions ] && . /etc/init.d/functions

[ $(id -u) != "0" ] && echo "Error: You must be root to run this script" && exit 1

sed -i "s/SELINUX=enforcing/SELINUX=disabled/" /etc/selinux/config

setenforce 0

clear

echo "########################################"

echo "# Auto Install Python ##"

echo "# Press Ctrl + C to cancel ##"

echo "# Any key to continue ##"

echo "########################################"

echo "(1) Install Python2.7"

echo "(2) Install zabbix3.6"

echo "(3) Install zabbix3.7"

echo "(4) EXIT"

read -p "Please input your choice:" NUM

case $NUM in

1)

URL="https://www.python.org/ftp/python/2.7/Python-2.7.tgz"

VER=python27

;;

2)

URL="https://www.python.org/ftp/python/3.6.0/Python-3.6.0.tgz"

VER=python36

;;

3)

URL="https://www.python.org/ftp/python/3.7.0/Python-3.7.0b4.tgz"

VER=python37

;;

4)

echo -e "\033[41;37m You choice channel! \033[0m" && exit 0

;;

*)

echo -e "\033[41;37m Input Error! Place input{1|2|3|4} \033[0m" && exit 1

;;

esac

clear

echo -e "\033[41;37m You choice $VER \033[0m"

}

download_software() {

softdir="/software"

if [ ! -d ${softdir} ];then

mkdir ${softdir} && cd ${softdir}

else

cd ${softdir}

fi

wget -c ${URL} -O python.tgz

wget -c https://bootstrap.pypa.io/get-pip.py

if [ $? -eq 0 ];then

tar zxf python.tgz -C /tmp

fi

}

install() {

yum install -y zlib-devel zlib readline-devel openssl-devel wget gcc-c++ libffi-devel

if [ ${VER} == "python27" ];then

dirname="Python-2.7.0"

elif [ ${VER} == "python36" ];then

dirname="Python-3.6.0"

else

dirname="Python-3.7.0b4"

fi

cd /tmp/${dirname}

./configure --prefix=/usr/local/${VER}

make && make install

echo "export PATH=$PATH:/usr/local/${VER}/bin">/etc/profile.d/${VER}.sh && source /etc/profile.d/${VER}.sh

#/usr/local/${VER}/bin/python /tmp/get-pip.py

rm -rf /tmp/${VER}

echo "/usr/local/${VER}/lib">/etc/ld.so.conf.d/${VER}.conf

ldconfig

}

main() {

sys_init

download_software

install

}

main

三、示例

watermark,size_16,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_100,g_se,x_10,y_10,shadow_90,type_ZmFuZ3poZW5naGVpdGk=

watermark,size_16,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_100,g_se,x_10,y_10,shadow_90,type_ZmFuZ3poZW5naGVpdGk=

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值