自定义编译安装python简单笔记

python:centos6默认版本2.6,如果想要获得更高版本,编译安装是不错的选择

1、自定义安装,不需要刻意直接制定目录或者文件删除即可。

2、yum安装的因为有依赖关系,yum直接卸载可能影响其它程序。

3、python高版本会增加一些功能。

官网:https://www.python.org/ 下载链接:https://www.python.org/downloads/  linux目前最新版本2.7.x

[[email protected] ~]# python

python     python2    python2.6  

[[email protected] ~]# python

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

安装:

 

[[email protected] ~]# wget https://www.python.org/ftp/python/2.7.8/Python-2.7.8.tgz^C

[[email protected] ~]# ls

Python-2.7.8.tgz

[[email protected] ~]#

[[email protected] ~]# tar xf Python-2.7.8.tgz 

[[email protected] ~]# cd Python-2.7.8

[[email protected] Python-2.7.8]#

[[email protected] Python-2.7.8]#./configure --prefix=/usr/local/python-2.7

[[email protected] Python-2.7.8]#make

[[email protected] Python-2.7.8]#make install

#配置环境变量:(最好不要配置在profile里面,而是单独配置。)

#vim /etc/profile.d/python2.7.sh

 

#[[email protected] profile.d]# cat python.2.7 

#export python=/usr/local/python-2.7/bin/

#[[email protected] profile.d]#

如果用新的python,则可以把旧的python备份。

[[email protected] bin]# cd /usr/bin

[[email protected] bin]# mv python python.bak

[[email protected] bin]# ln -s /usr/local/python-2.7/bin/python /usr/bin/

[[email protected] bin]# python

Python 2.7.8 (default, Sep  5 2016, 17:22:38) 

[GCC 4.4.7 20120313 (Red Hat 4.4.7-17)] on linux2

Type "help", "copyright", "credits" or "license" for more information.

>>>

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

python模板安装:

官方参考文档:https://docs.python.org/2.7/

模板安装官方参考文档:https://docs.python.org/2.7/installing/index.html

 

登录乐搏学院官网http://www.learnbo.com/

或关注我们的官方微博微信,还有更多惊喜哦~

自定义编译安装python简单笔记

 

本文出自 “永不放弃!任志远” 博客,转载请与作者联系!

转载于:https://my.oschina.net/learnbo/blog/907988