安装Python依赖包:
[[email protected] src]# yum install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gcc make
下载Python源码包:
[[email protected] src]# wget ttp://mirrors.sohu.com/python/3.6.4/Python-3.6.4.tgz
编译、安装:
[[email protected] /]# tar -xzvf /usr/local/src/Python-3.6.4.tgz -C /usr/local/src/
[[email protected] /]# cd /usr/local/src/Python-3.6.4
[[email protected] Python-3.6.4]# ./configure --prefix=/usr/local/python
[[email protected] Python-3.6.4]# make -j 4
[[email protected] Python-3.6.4]# make install
查看扩展安装包:
[[email protected] /]# /usr/local/python/bin/pip3 list
pip (8.1.1) setuptools (20.10.1)
添加Python命令到环境变量:
[[email protected] /]# vim ~/.bash_profile
PATH=$PATH:$HOME/bin
改为:
PATH=$PATH:$HOME/bin:/usr/local/python/bin
使环境变量生效:
[[email protected] /]# source ~/.bash_profile
查看Python版本:
[[email protected] /]# python3 -V
Python 3.6.4
更改系统默认python版本为Python3.6
[[email protected] /]# mv /usr/bin/python /usr/bin/python2.6
[[email protected] /]# ln -s /usr/local/python/bin/python3.6 /usr/bin/python
核对Python版本:
[[email protected] /]# python -V
Python 3.6.4
解决python升级后,YUM不能正常工作的问题:
#vi /usr/bin/yum
将文件头部的 #!/usr/bin/python
改成 #!/usr/bin/python2.6
原文地址:https://www.cnblogs.com/music378/p/8267370.html
时间: 2024-10-08 07:25:20