python3.8

以下是脚本,根据自己的路径进行修改。

cd /home/projects
echo "------------------------------yum install libffi-devel------------------------------"
yum install libffi-devel
wget http://www.python.org/ftp/python/3.8.13/Python-3.8.13.tgz
read -p "下载完成,是否继续?"
echo "----------------------------解压-----------------------"
pwd
tar zxvf Python-3.8.13.tgz
echo "------------------------------查看当前python3的位置并备份------------------------------"
python3_path=`which python3` # /usr/bin/python3
python3_path="/usr/bin/python3"
mv $python3_path "$python3_path-old"
cd Python-3.8.13
read -p '备份完成,继续?'
echo "------------------------------创建编译安装目录------------------------------"
mkdir /usr/local/python3
echo "------------------------------编译------------------------------"
./configure --prefix=/usr/local/python3
make
echo"----------------------make install--------------------------------------"
make install
echo"----------------------创建软链接--------------------------------------"
ln -s /usr/local/python3/bin/python3 /usr/bin/python3
ln -s /usr/local/python3/bin/pip3 /usr/bin/pip3
read -p "完成配置,查看当前版本?"
echo"----------------------查看新的python--------------------------------------"
ls -l /usr/bin/python3
ls -l /usr/bin/pip3
python3 -V
pip3 -V
read -p "安装依赖"

# 前提是项目已经生成requirent.txt 生成命令requirement.txt: pip3 freeze >requirent.txt
pip3 install -r ./requirent.txt

# 如果下载不成功,更换pip源
mkdir ~/.pip
touch ~/.pip/pip.conf
vim ~/.pip/pip.conf

[global]
timeout=40
index-url=https://pypi.tuna.tsinghua.edu.cn/simple/
extra-index-url=
        http://mirrors.aliyun.com/pypi/simple/
        http://pypi.douban.com/simple
        http://pypi.mirrors.ustc.edu.cn/simple/

[install]
trusted-host=
        pypi.tuna.tsinghua.edu.cn
        mirrors.aliyun.com
        pypi.douban.com
        pypi.mirrors.ustc.edu.cn

猜你喜欢

转载自blog.csdn.net/fvafuc/article/details/128497658