在 Debian 上安装 Python2 + Python3 环境

默认安装了Python OCR,requests等…

#因为之前是自用的,现在有人有需求就放出来了.
#默认用萌咖自己的谷歌网盘,可自行替换.(其实是萌咖太懒了)
# Python2 用 pip 安装支持库.
# Python3 用 pip3 安装支持库.

wget --no-check-certificate -qO- 'https://moeclub.org/attachment/LinuxShell/InsPy.sh' |bash

脚本预览:

#!/bin/bashfunction CACHEFILE()
{
NoCache=0;
NoError=0;
[ $# != '2' ] && NoCache=1 && NoError=1 && printf "\e[31m* Error! \e[0m\n\e[31m* Please select \e[33m[\e[32m0\e[0m.\e[35mGo to Menu\e[33m/1\e[0m.\e[35mIgnore\e[33m]\e[0m: ";
[ -n "$2" ] && [ "$NoError" = '0' ] && [[ -n "$(echo "$2" |grep '://')" ]] && GLINK='0' || GLINK='1';
[ -f "$1" ] && [ "$NoError" = '0' ] && [ "$(du "$1" |awk '{ print $1 }')" == '0' ] && rm -rf "$1";
[ ! -f "$1" ] && [ "$NoError" = '0' ] && [ -n "$2" ] && [ $GLINK = '0' ] && wget --no-check-certificate -q -O "${1}" "${2}";
[ ! -f "$1" ] && [ "$NoError" = '0' ] && [ -n "$2" ] && [ $GLINK = '1' ] && wget --no-check-certificate -q -O "${1}" "https://docs.google.com/uc?id="${2}"&export=download";
[ ! -f "$1" ] && [ "$NoError" = '0' ] && NoCache=1 && printf "\e[31m* \e[31mNot Found \e[35m"$1"\e[31m File ID! \e[0m\n\e[31m* Please select \e[33m[\e[32m0\e[0m.\e[35mGo to Menu\e[33m/1\e[0m.\e[35mIgnore\e[33m]\e[0m: ";
[ -f "$1" ] && [ "$NoError" = '0' ] && [ "$(du "$1" |awk '{ print $1 }')" == '0' ] && rm -rf "$1" && NoCache=1 && printf "\e[31m* \e[35m"$1"\e[31m Not Found! \e[0m\n\e[31m* Please select \e[33m[\e[32m0\e[0m.\e[35mGo to Menu\e[33m/1\e[0m.\e[35mIgnore\e[33m]\e[0m: ";
[ "${NoCache}" == '1' ] && {
CFC='' && read CFC;
[ "${CFC}" == '1' ] || menu;
} }function APTINSTALL(){    for DEB_IN in ${1}
    do
        echo -n -e "Installing package\e[36m ${DEB_IN} \e[0m"
        DEBIAN_FRONTEND=noninteractive apt-get install -qq -y ${2} ${DEB_IN} >/dev/null 2>&1        if [ $? -eq 0 ]; then
            echo -e "[\e[32mok\e[0m]"
        else
            [ -n "${2}" ] && DEBIAN_FRONTEND=noninteractive apt-get install -qq -y ${DEB_IN} >/dev/null 2>&1            if [ $? -eq 0 ]; then
                echo -e "[\e[32mok\e[0m]"
            else
                echo -e "[\e[31mfail\e[0m]"
        fi  fi
    done}function InsPy()
{
APTINSTALL "build-essential make gcc zlib1g-dev libssl-dev libffi-dev python-dev libxml2-dev libxslt-dev python3-pip tesseract-ocr enca"printf "\e[36mInstall Python2 ...\e[0m\n"cd /tmp
CACHEFILE "/tmp/Python2.tgz" "0B783U-qC53BDdzJsRldoS2hYcEE"CACHEFILE "/tmp/pip.py" "0B783U-qC53BDMjBaREl5U0hUeEE"CACHEFILE "/tmp/ocr.eng.tar.gz" "0B783U-qC53BDNnZjQjhWdkdFbjg"pip install requests Pillow pytesseract
tar -xvf /tmp/ocr.eng.tar.gz -C /tmp
mkdir -p /usr/local/share/tessdata
cp -f /tmp/tesseract-ocr/tessdata/* /usr/local/share/tessdata
tar -xzvf Python2.tgzcd Python-2*
sed -i s'/^#zlib zlibmodule.c -I\$(prefix)\/include -L\$(exec_prefix)\/lib -lz$/zlib zlibmodule.c -I\$(prefix)\/include -L\$(exec_prefix)\/lib -lz/' ./Modules/Setup
./configure --prefix=/usr/localmake && make install
python /tmp/pip.pyprintf "\e[36mInstall Python3 ...\e[0m\n"cd /tmp
CACHEFILE "/tmp/Python3.tgz" "0B783U-qC53BDNjg1VXpHdU1rbG8"tar -xzvf Python3.tgzcd Python-3*
./configure --prefix=/usr/localmake && make install
pip3 install requests
clear
}

InsPy;

发表评论

电子邮件地址不会被公开。 必填项已用*标注