CentOS7编译安装Python3.6.3

来源:互联网 发布:clean my mac有必要吗 编辑:程序博客网 时间:2024/06/06 00:35

系统环境:CentOS 7.3.10.0-693.el7.x86_64
前言:CentOS 7环境下已经自带了python2.7环境,但是如果需要使用最新的Python3则需要自行编译安装,以下为安装过程。
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 wget

2、wget Python3.6.3;创建程序目录;编译安装

# wget https://www.python.org/ftp/python/3.6.3/Python-3.6.3.tgz# mkdir -p /usr/local/python3# tar -zxvf Python-3.6.3.tgz# cd Python-3.6.3/# ./configure --prefix=/usr/local/python3 && make && make install

如无意外,则会安装完成,如有意外,请自行度娘解决!!!
3、建立Python3的软链接,并将/usr/local/python3/bin加入bash_profile

# ln -s /usr/local/python3/bin/python3 /usr/bin/python3# vim ~/.bash_profile
# .bash_profile# Get the aliases and functionsif [ -f ~/.bashrc ]; then    . ~/.bashrcfi# User specific environment and startup programs##下面这句为添加内容PATH=$PATH:$HOME/bin:/usr/local/python3/binPATH=$PATH:$HOME/binexport PATH

然后

# source ~/.bash_profile

查看Python3.6.3 pip3是否正常

# python3 -VPython 3.6.3# pip3 -Vpip 9.0.1 from /usr/local/python3/lib/python3.6/site-packages (python 3.6)

至此,Python3.6.3安装完毕,如出现其他错误可在评论区留言指出。

原创粉丝点击