美文网首页
Linux安装Python3.7

Linux安装Python3.7

作者: 朝朝朝朝朝落 | 来源:发表于2021-05-18 10:11 被阅读0次

1, 安装依赖环境

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

2, 下载压缩包(如果找不到wget命令: yum -y install wget)

wget https://www.python.org/ftp/python/3.7.1/Python-3.7.1.tgz

3, 解压

tar -zxvf Python-3.7.1.tgz

4, 进入解压后的目录(Python-3.7.1),编译安装, (确认 y )

yum install gcc

3.7版本之后需要一个新的包libffi-devel, 安装

yum install libffi-devel -y

进入python文件夹,生成编译脚本(指定安装目录)

创建目录:  
mkdir -p /usr/local/python3

./configure --prefix=/usr/local/python3

5, 编译

make

6, 编译安装

make install

检查

/usr/local/python3/bin/python3.7

7, 建立Python3和pip3的软链:

ln -s /usr/local/python3/bin/python3 /usr/bin/python3
ln -s /usr/local/python3/bin/pip3 /usr/bin/pip3

将/usr/local/python3/bin加入PATH

vim /etc/profile
粘贴: 
# vim ~/.bash_profile

# .bash_profile

# Get the aliases and functions

if [ -f ~/.bashrc ]; then

. ~/.bashrc

fi

# User specific environment and startup programs

PATH=$PATH:$HOME/bin:/usr/local/python3/bin

export PATH

source /etc/profile

相关文章

网友评论

      本文标题:Linux安装Python3.7

      本文链接:https://www.haomeiwen.com/subject/aiaujltx.html