centOS7环境下安装Python3(2018.06)
centos7已经自带了Python2.7环境,但是不能卸载了,因为系统很多命令用的这个环境,通过which python可以知道安装的位置[root@master Python-3.6.2]# pythonPython 2.7.5 (default, Nov6 2016, 00:28:07)[GCC 4.8.5 20150623 (Red Hat 4.8.5-11)] on l...
·
centos7已经自带了Python2.7环境,但是不能卸载了,因为系统很多命令用的这个环境
,通过which python可以知道安装的位置
[root@master Python-3.6.2]# python
Python 2.7.5 (default, Nov 6 2016, 00:28:07)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-11)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> exit()
[root@master Python-3.6.2]# which python
/usr/bin/python
安装Python3环境
执行下面两个命令:
# yum -y groupinstall "Development tools"
# 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
在线下载安装包:
本人用的是3.6.2版,其他版自己在官网找到链接,然后通过wget下载
官网地址:https://www.python.org/downloads/source/
wget https://www.python.org/ftp/python/3.6.2/Python-3.6.2.tar.xz
创建一个Python3的文件夹
# mkdir /usr/local/python3
解压刚刚下载的文件,进入解压后的文件夹,再继续操作
# tar -xvJf Python-3.6.2.tar.xz
# cd Python-3.6.2
# ./configure --prefix=/usr/local/python3
# make
# make install
如果make命令没有安装的可以执行下面安装一下,在执行上面步骤
#yum install make
#yum install cmake
#yum install cmake
make install命令执行完后,/usr/local/python3会有文件,最后创建软链接
# ln -s /usr/local/python3/bin/python3 /usr/bin/python3
# ln -s /usr/local/python3/bin/pip3 /usr/bin/pip3
最后输入python3测试是否已安装成功
[root@master Python-3.6.2]# python3
Python 3.6.2 (default, Jun 27 2018, 17:07:22)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-28)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> exit()
[root@master Python-3.6.2]#
更多推荐
已为社区贡献1条内容
所有评论(0)