Linux中默认是安装了Python的,默认安装的版本是Python 2。(测试环境是CentOS 6.3)
![](https://img.haomeiwen.com/i5796945/b6dc83aaad80ca77.png)
安装Python 3的话,不建议卸载Python2,否则后面你可能会因为缺少依赖包或者文件,还需要自己重新下载安装这些包。当然如果你有 洁癖 的话,也完全可以卸载Python 2。
安装前需要准备的
安装前需要确认系统中是否已经安装必要的开发依赖
# yum -y groupinstall development
![](https://img.haomeiwen.com/i5796945/1d645aaa7a4dab1b.png)
# yum -y install zlib-devel
![](https://img.haomeiwen.com/i5796945/7d642198750f6311.png)
确保这些依赖安装成功后,我们就可以开始安装Python啦
开始安装
使用如下命令,获取Python3.6.1压缩安装包
# wget https://www.python.org/ftp/python/3.6.1/Python-3.6.1.tar.xz
![](https://img.haomeiwen.com/i5796945/092f33a4e235f0c2.png)
解压
tar xJf Python-3.6.1.tar.xz
![](https://img.haomeiwen.com/i5796945/3696617e3fbf010a.png)
切换到解压后的安装包文件夹中
# cd Python-3.6.1
![](https://img.haomeiwen.com/i5796945/19e28f82889d6ecb.png)
检查包
# ./configure
编译 并 安装
# make && make install
看到 Successfully installed 则代表安装成功
![](https://img.haomeiwen.com/i5796945/01689a3e1a1e0eae.png)
你已经可以通过python3命令进入python的交互模式,并查看安装的版本信息
![](https://img.haomeiwen.com/i5796945/af16d4d7e0af6607.png)
输入 exit() 或 quit() 命令退出交互模式
网友评论