侧边栏壁纸
博主头像
平凡的运维之路博主等级

行动起来,活在当下

  • 累计撰写 49 篇文章
  • 累计创建 25 个标签
  • 累计收到 3 条评论

目 录CONTENT

文章目录

一键部署Python3版本

平凡的运维之路
2024-08-19 / 0 评论 / 0 点赞 / 82 阅读 / 2155 字

一键部署Python3版本

  • 具体脚本
#!/bin/bash
install_python3(){
	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 wget gcc libffi-devel 
    wget https://zhao138969.com/LinuxPackage/Linux/Python-3.7.5.tgz
    get_file_md5=$(md5sum Python-3.7.5.tgz|awk '{print $1}')
    if [ $get_file_md5 ==  "1cd071f78ff6d9c7524c95303a3057aa" ];then
	    tar xvf Python-3.7.5.tgz
	    cd Python-3.7.5
        ./configure --enable-shared --prefix=/usr/local/python3 -enable-unicode=ucs4 
         make -j 2 && make install
        # 添加Python环境变量到/etc/profile
	    echo "export PYTHON_HOME=/usr/local/python3" >>/etc/profile
	    echo "export PATH=\${PATH}:\${PYTHON_HOME}\"/bin\"" >>/etc/profile
	    source /etc/profile
	    # 设置Python安装镜像源为阿里云
	    pip config set global.index-url https://mirrors.aliyun.com/pypi/simple
        echo 'pip3 config set global.index-url https://mirrors.aliyun.com/pypi/simple' >> ~/.bash_profile
        echo 'export LD_LIBRARY_PATH=/usr/local/python3/lib' >> ~/.bash_profile
        echo 'export python_home=/usr/local/python3' >> ~/.bash_profile
        echo 'export PATH=$PATH:$python_home/bin' >>  ~/.bash_profile
        source ~/.bash_profile
        pip list
	    echo "=====`date`===== Python-3.7.5 install success !!!====="
    else
          echo download Python-3.7.5.tgz file error
    fi 
}

install_python3
  • 具体安装
curl  -s   https://zhao138969.com/LinuxPackage/Linux/install_pyhton3.sh |bash
0

评论区