官网源码下载:https://www.python.org/downloads/source/
编译安装:
先安装:
yum -y install zlib zlib-devel
yum -y install gcc
yum install libffi-devel -y
yum -y install bzip2 bzip2-devel
yum -y install ncurses ncurses-devel
yum -y install readline readline-devel
yum -y install openssl openssl-devel
yum -y install openssl-static
yum -y install xz lzma xz-devel
yum -y install sqlite sqlite-devel
yum -y install gdbm gdbm-devel
yum -y install tk tk-devel
yum install bzip2-devel ncurses-devel gdbm-devel openssl-devel readline-devel lzma xz-devel zlib-devel sqlite-devel python-devel(python3-devel,根据python版本选择)
配置后安装:
./configure --prefix=/usr/local/python3.4 --enable-shared --enable-loadable-sqlite-extensions
修改yum文件,有python改为python2
yum命令:
vim /usr/bin/yum
#!/usr/bin/python2
yum命令中下载文件:
vi /usr/libexec/urlgrabber-ext-down
#! /usr/bin/python2
对原python改名:
mv /usr/bin/python /usr/bin/python.old
创建新的链接文件
ln -s /usr/local/python3/bin/python3 /usr/bin/python
ERROR:
./python3: error while loading shared libraries: libpython3.4m.so.1.0: cannot open shared object file: No such file or directory
复制源码下的libpython3.4m.a,libpython3.4m.so,libpython3.4m.so.1.0,libpython3.so 到/usr/lib目录下
load刚复制的模块:/sbin/ldconfig
建立软链接:ln -s /usr/local/python3.4/bin/python3 /usr/bin/python
Ubuntu编译安装软件提示:编译器无法创建可执行文件,卸载到gcc和g++后重新安装
sudo apt-get install build-essential