首页 > 代码库 > CentOS6.5源码安装python3.5.2

CentOS6.5源码安装python3.5.2

前提:

1、实现自动补全需要安装模块 readline-devel (yum install -y readline-devel)

2、实现支持SSL协议需安装模块 openssl-devel (yum install -y openssl-devel)

安装步骤

1、下载python3.5源码包到/usr/local/src/ (https://www.python.org/ftp/python/3.5.2/Python-3.5.2.tgz)

2、 tar xf Python-3.5.2.tgz

  cd Python-3.5.2

  ./configure --prefix=/usr/local/python-3.5.2

  make && make >python_install.log

3、设置PATH(里面包含pip3) echo "PATH=$PATH:/usr/local/python-3.5.2/bin">>  /etc/profile.d/python.sh

4、设置默认python路径

  (1) which python    ----> /usr/bin/python

  (2) rm -rf /usr/bin/python

  (3) ln -s /usr/local/python3.5.2/bin/python /usr/bin/python

  (4) 修改/usr/bin/yum中python路径为/usr/bin/python2(yum中python只支持原python)

注释:因为python3.5.2中已安装了pip(python包管理工具),故不需要再安装

其他版本如没有安装pip,需要再安装,源码安装:需要先安装setuptools-28.8.0(python setup.py install),之后安装pip-9.0.1(python setup.py install)

具体安装内容参考:https://pip.pypa.io/en/stable/installing/#installing-with-get-pip-py

 

CentOS6.5源码安装python3.5.2