安装python3
1.安装依赖
yum install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gcc* make -y
2.下载对应版本python安装包(我这里是3.7.5)
wget https://www.python.org/ftp/python/3.7.5/Python-3.7.5.tar.xz
3.解压缩python安装包
tar -Jxvf Python-3.7.5.tar.xz
4.配置安装路径(注意大小写!)
cd Python-3.7.5
./configure prefix=/usr/local/python3
5.编译安装
cd Python-3.7.5
make && make install
6.配置符号连接
如果提示文件已存在,不必重复执行
cd /bin
ln -s /usr/local/python3/bin/python3 /usr/bin/python3
ln -s /usr/local/python3/bin/pip3 /usr/bin/pip3
7.至此成功安装了Python
python -V
pyenv: python: command not found
The `python' command exists in these Python versions:
3.7.5
python3
print('Hello World~')
Hello World~
8.如果步骤7提示未找到命令python,可尝试设置默认python版本
pyenv local 3.7.5
python -V
Python 3.7.5
9.卸载python命令
rpm -qa|grep python2|xargs rpm -ev --allmatches --nodeps
whereis python2 |xargs rm -frv
10.查看现有python
whereis python
完
感谢作者 Python及时行乐 思路。