centos6安装python3

朋友的新机器,python3是python未来的趋势,安装在本机的python2千万别动。

踩了一些坑,安装如下步骤操作顺利通过。

安装前需要安装如下依赖关系

# yum install gcc zlib-devel openssl-devel

安装python3.5

wget https://www.python.org/ftp/python/3.5.2/Python-3.5.2.tar.xz
tar xf Python-3.5.2.tar.xz
cd Python-3.5.2
./configure --prefix=/usr/local/python3 --enable-shared
make -j 4
make install
ln -s /usr/local/python3/bin/python3 /usr/local/bin
cat > /etc/ld.so.conf.d/python3.conf << EOF
/usr/local/python3/lib/
EOF
ldconfig

安装setuptools

wget https://pypi.python.org/packages/source/s/setuptools/setuptools-19.6.tar.gz
tar xf setuptools-19.6.tar.gz
cd setuptools-19.6
python3 setup.py build
python3 setup.py install

安装pip

wget https://pypi.python.org/packages/source/p/pip/pip-8.0.2.tar.gz
tar xf pip-8.0.2.tar.gz
cd pip-8.0.2
python3 setup.py build
python3 setup.py install
ln -s /usr/local/python3/bin/pip3 /usr/local/bin

OK,完成了整个python3环境的安装。