首先安装依赖包,centos里面是-devel,如果在ubuntu下安装则要改成-dev,依赖包缺一不可,笔者曾安装python3未成功就是因为没有安装libffi-devel
yum -y install gcc zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel libffi-devel
然后获取python3.7的安装包
wget https://www.python.org/ftp/python/3.7.0/Python-3.7.0.tar.xz
解压
tar -xvJf Python-3.7.0.tar.xz
配置python3的安装目录并安装
cd Python-3.7.0
./configure --prefix=/usr/local/bin/python3
make
make install
创建软链接
ln -s /usr/local/bin/python3/bin/python3 /usr/bin/python(如果文件存在,删除之前的)
ln -s /usr/local/bin/python3/bin/pip3 /usr/bin/pip3
出现上面就表示成功!!!
由于yum默认是python2.x
修改vim /usr/bin/yum
将python 改为python2.7(你的版本)即可.
还有使用中的其他文件报错,解决方法和上面一样修改为python2.7
原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/tech/pnotes/17481.html