在 Centos7 上安装 Python3

2016-07-05  王恩建 

Linux 自带了 Python2,所以 Python2 就不用装了。要用 Python3,得辛苦一下自己装,不过注意,不要卸载或者覆盖 Python2,因为 Linux 好多软件是基于 Python2开发的,例如 yum,删了就没得用。


1、从 Python 官网下载源码包

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

2、安装 Python 依赖的第三方包
#yum install openssl-devel libxslt-devel -y


3、解压缩源码包然后编译安装。
#./configure --prefix=/usr/python3.5
#make
#make install 

4、将 Python3添加到系统环境中
#vi /etc/profile
export PATH=$PATH:/usr/python3.5/bin

#. /etc/profile


5、验证一下是否安装成功,输出下面内容就成功。

#python3

[GCC 4.8.5 20150623 (Red Hat 4.8.5-4)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>

780°/7805 人阅读/0 条评论 发表评论

登录 后发表评论