下载
wget https://www.python.org/ftp/python/3.5.0/Python-3.5.0.tar.xz
解压
tar xvf Python-3.5.0.tar.xz
cd Python-3.5.0
指定路径安装
./configure --prefix=/usr/local/python3
make
make install
建立软连接
#不要覆盖原来版本的链接,所以最好起名python3
ln -s /usr/local/python3/bin/python3 /usr/bin/python3
测试
python
二.安装pip
首先安装setuptools
yum install zlib-devel
从新编译python3
cd /usr/local/python3
make
make install
#执行这一步遇上一个错误,内容如下
[root@liulao Python-3.5.0]# ./configure --prefix=/usr/local/python3
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking for --enable-universalsdk... no
checking for --with-universal-archs... no
checking MACHDEP... linux
checking for --without-gcc... no
checking for gcc... no
checking for cc... no
checking for cl.exe... no
configure: error: in `/HelloWorld/Python-3.5.0':
configure: error: no acceptable C compiler found in $PATH
See `config.log' for more details
缺少一些软件包
yum 下载
yum install -y cc gcc cl.exe without-gcc with-universal-archs enable-universalsdk
#反正我装好之后就可以了
下载安装setuptools
wget –no-check-certificate https://pypi.python.org/packages/source/s/setuptools/setuptools-19.6.tar.gz#md5=c607dd118eae682c44ed146367a17e26
tar -zxvf setuptools-19.6.tar.gz
cd setuptools-19.6
python3 setup.py build
python3 setup.py install
安装pip
wget –no-check-certificate https://pypi.python.org/packages/source/p/pip/pip-8.0.2.tar.gz#md5=3a73c4188f8dbad6a1e6f6d44d117eeb
tar -zxvf pip-8.0.2.tar.gz
cd pip-8.0.2
python3 setup.py build
python3 setup.py install
如果报错。可能是缺少环境
yum install openssl-devel #完成后从新编译python3
建立软连接
ln -s /usr/local/python3/bin/pip /usr/bin/pip
测试
输入python3