安装相关包:
yum install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gcc make
下载安装文件:
从网站查询安装版本 http://mirrors.sohu.com/python
比如:http://mirrors.sohu.com/python/3.6.0/Python-3.6.0a1.tar.xz
# xz -d Python-3.6.0a1.tar.xz
# tar xf Python-3.6.0a1.tar -C /usr/local/src/
# cd /usr/local/src/Python-3.6.0/
# ./configure --prefix=/usr/local/python36
# make -j8 && make install
可选步骤,环境变量:vim ~/.bash_profile
安装过程:
tar -zxvf Python-3.6.0.tgz
cd Python-3.6.0
./configure --prefix=/usr/python
make
make install
配置:
查看之前的版本,看到是个软连接
ll /usr/bin/python
重命名创建修改软连接
[root@centos7 Python-3.6.0]# ll /usr/bin/python
lrwxrwxrwx. 1 root root 7 12月 16 08:48 /usr/bin/python -> python2
[root@centos7 Python-3.6.0]# mv /usr/bin/python /usr/bin/python.bak
[root@centos7 Python-3.6.0]# ln -s /usr/python/bin/python3 /usr/bin/python
[root@centos7 Python-3.6.0]# python
Python 3.6.0 (default, Dec 28 2016, 08:56:17)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-11)] on Linux
Type "help", "copyright", "credits" or "license" for more information.
>>> print('hell0')
hell0
yum install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gcc make
下载安装文件:
从网站查询安装版本 http://mirrors.sohu.com/python
比如:http://mirrors.sohu.com/python/3.6.0/Python-3.6.0a1.tar.xz
# xz -d Python-3.6.0a1.tar.xz
# tar xf Python-3.6.0a1.tar -C /usr/local/src/
# cd /usr/local/src/Python-3.6.0/
# ./configure --prefix=/usr/local/python36
# make -j8 && make install
可选步骤,环境变量:vim ~/.bash_profile
PATH=$PATH:/usr/local/python36/bin
如果之前有安装了python2情况下,安装方式,
从网站下载 Python :https://www.python.org/downloads/release/python-360/安装过程:
tar -zxvf Python-3.6.0.tgz
cd Python-3.6.0
./configure --prefix=/usr/python
make
make install
配置:
查看之前的版本,看到是个软连接
ll /usr/bin/python
重命名创建修改软连接
[root@centos7 Python-3.6.0]# ll /usr/bin/python
lrwxrwxrwx. 1 root root 7 12月 16 08:48 /usr/bin/python -> python2
[root@centos7 Python-3.6.0]# mv /usr/bin/python /usr/bin/python.bak
[root@centos7 Python-3.6.0]# ln -s /usr/python/bin/python3 /usr/bin/python
[root@centos7 Python-3.6.0]# python
Python 3.6.0 (default, Dec 28 2016, 08:56:17)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-11)] on Linux
Type "help", "copyright", "credits" or "license" for more information.
>>> print('hell0')
hell0