CentOS安装Python

时光毁灭记忆、已成空白 提交于 2019-12-01 18:28:00

一、Python源代码编译安装

yum -y install wget
yum -y install zlib zlib-devel
yum -y install bzip2 bzip2-devel
yum -y install ncurses ncurses-devel
yum -y install readline readline-devel
yum -y install openssl openssl-devel
yum -y install openssl-static
yum -y install xz lzma xz-devel
yum -y install sqlite sqlite-devel
yum -y install gdbm gdbm-devel
yum -y install tk tk-devel
yum -y install gcc

wget https://www.python.org/ftp/python/3.6.3/Python-3.6.3.tgz
tar xf Python-3.6.3.tgz 
cd Python-3.6.3
yum install gcc
./configure --prefix=/usr/local/python3.6 --enable-optimizations
make

ln -s /usr/local/python3.6/bin/python3 /usr/bin/python3

二、一键安装Python

#!/bin/bash

#Install Dependence
yum -y install wget
yum -y install zlib zlib-devel
yum -y install bzip2 bzip2-devel
yum -y install ncurses ncurses-devel
yum -y install readline readline-devel
yum -y install openssl openssl-devel
yum -y install openssl-static
yum -y install xz lzma xz-devel
yum -y install sqlite sqlite-devel
yum -y install gdbm gdbm-devel
yum -y install tk tk-devel
yum -y install gcc

#Install Python3
wget https://www.python.org/ftp/python/3.6.4/Python-3.6.4.tgz
tar -xvf Python-3.6.4.tgz && cd Python-3.6.4/
./configure --prefix=/usr/python3  --enable-optimizations
make && make install && echo "### Python3 install success!"

#Creating Soft Link
if [ -f "/usr/bin/python3" ];then
rm -rf /usr/bin/python3 && ln -s /usr/python3/bin/python3 /usr/bin/python3 && echo "### Add python3 link Done!"
else
ln -s /usr/python3/bin/python3 /usr/bin/python3 && echo "### Add python3 link Done!"
fi
if [ -f "/usr/bin/pip3" ];then
rm -rf /usr/bin/pip3 && ln -s /usr/python3/bin/pip3 /usr/bin/pip3 && echo "### Add pip3 link Done!"
else
ln -s /usr/python3/bin/pip3 /usr/bin/pip3 && echo "### Add pip3 link Done!"
fi
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!