0%

CentOS 安装Python3

安装Python3

CentOS自带的是Python2
这里提供Python3的安装方法

安装依赖

1
sudo yum -y groupinstall "Development tools"
1
sudo 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 libffi-devel

安装

  • 下载
1
wget https://www.python.org/ftp/python/3.7.0/Python-3.7.0a1.tar.xz
  • 解压
1
tar -xvJf Python-3.7.0a1.tar.xz
  • 切换到解压目录
1
cd Python-3.7.0a1
  • 配置 编译 安装
1
./configure preix=/usr/local/python3
1
sudo make
1
sudo make install

设置软链

1
ln -s /usr/local/python3/bin/python3.7 /usr/bin/python3
1
ln -s /usr/local/python3/bin/pip3 /usr/bin/pip3

注:如何删除软链,用rm命令即可

1
rm /usr/bin/pip3