当前版本:python -V

`<span style="background-color: inherit;">Python</span> <span style="background-color: inherit;">2.7</span>.<span style="background-color: inherit;">5</span>`

安装python3.5<span style="text-align: left; color: rgb(0, 0, 0); font-family: 微软雅黑; font-size: 14px; font-style: normal; font-weight: normal; background-color: rgb(255, 255, 255);">依赖包</span>

yum install openssl-devel bzip2-devel expat-devel gdbm-devel readline-devel sqlite-devel

&nbsp;

##

CentOS6.5 安装Python 的依赖包

yum -y groupinstall &quot;Development tools&quot;

yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel

##

<span style="line-height: 1.5; background-color: inherit;">官网下载,&nbsp;</span>

wget&nbsp;<span style="background-color: inherit;">https://www.python.org/ftp/python/3.5.2/Python-3.5.2.tgz</span>

 


tar -zxvf Python-3.5.2.tgz
<div style="background-color: inherit;">
    cd&nbsp;<span style="line-height: 1.5; background-color: inherit;">Python-3.5.2</span>
</div>

<div style="background-color: inherit;">
    &nbsp;
</div>

<div style="background-color: inherit;">

###
安装说明—安装Python3.5.0与旧版本Python2.7.5共存

          我们必须不能破坏系统的环境。因为几个关键的应用程序依赖于Python 2.7.5。如果替换了系统的Python环境就会发生很多难以预见的错误,甚至要重装系统。<span style="background-color: inherit;">&nbsp;</span>

          我们使用make altinstall,如果使用make install,你将会看到在系统中有两个不同版本的Python在/usr/bin/目录中。这将会导致很多问题,而且不好处理。

</div>

<div style="background-color: inherit;">
    &nbsp;
</div>


编译环境时默认不生成动态库,加个–enable-shared才会生产动态库

 

./configure –prefix=/usr/local –enable-shared


 
<div style="background-color: inherit;">
    make
</div>

<div style="background-color: inherit;">
    make altinstall
</div>


 python程序的执行文件:/usr/local/bin/python3.5  

python应用程序目录:/usr/local/lib/python3.5 

 


ln -s /usr/local/bin/python3.5 /usr/bin/python3
<div style="background-color: inherit;">
    &nbsp;
</div>

<div style="background-color: inherit;">
    在运行Python之前需要配置库:
</div>

<div style="background-color: inherit;">
    &nbsp;
</div>

<div style="background-color: inherit;">
    echo /usr/local/lib &gt;&gt; /etc/ld.so.conf.d/local.conf
</div>

<div style="background-color: inherit;">
    ldconfig
</div>

<div style="background-color: inherit;">
    查看
</div>

<div style="background-color: inherit;">
    &nbsp;
</div>

<span style="font: 14px/21px 微软雅黑; text-align: left; color: rgb(0, 0, 0); text-transform: none; text-indent: 0px; letter-spacing: normal; word-spacing: 0px; float: none; display: inline !important; white-space: normal; font-size-adjust: none; font-stretch: normal; background-color: rgb(255, 255, 255); -webkit-text-stroke-width: 0px;">python3 --version</span>


 
<div style="background-color: inherit;">
    #如果是覆盖老版本#
</div>

<div style="background-color: inherit;">
    前面就是
</div>

<div style="background-color: inherit;">
    <span style="text-align: left; color: rgb(68, 68, 68); font-family: Tahoma, Helvetica, Arial, 宋体, sans-serif; font-size: 14px; font-style: normal; font-weight: normal; background-color: rgb(247, 252, 255);">make install</span>
</div>

<div style="background-color: inherit;">
    <span style="text-align: left; color: rgb(68, 68, 68); font-family: Tahoma, Helvetica, Arial, 宋体, sans-serif; font-size: 14px; font-style: normal; font-weight: normal; background-color: rgb(247, 252, 255);"><span style="text-align: left; color: rgb(0, 0, 0); font-family: 微软雅黑; font-size: 14px; font-style: normal; font-weight: normal; background-color: rgb(255, 255, 255);">rm&nbsp;-rf&nbsp;/usr/bin/python</span></span>
</div>

<div style="background-color: inherit;">
    删除旧的软链接,创建新的软链接到最新的python
</div>

<div style="background-color: inherit;">
    ll&nbsp;/usr/bin&nbsp;|&nbsp;grep&nbsp;python
</div>

<div style="background-color: inherit;">
    rm&nbsp;-rf&nbsp;/usr/bin/python
</div>

<div style="background-color: inherit;">
    &nbsp;
</div>

<div style="background-color: inherit;">
    ln&nbsp;-s&nbsp;/usr/local/bin/python3.5&nbsp;/usr/bin/python
</div>

<div style="background-color: inherit;">
    &nbsp;
</div>

<div style="background-color: inherit;">
    python&nbsp;-V
</div>


 

#####