CentOS 6安装python2.7和ipython Centos 6自带的python版本是2.6
[root@C6 ~]# pythonPython 2.6.6 (r266:84292, Nov 22 2013, 12:16:22)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>
如果想要安装2.7可以额外编译安装一个到指定的路径
第二种方法是使用pyenv
所需要的软件
Python-2.7.13.tgz
ipython-1.2.1.tar.gz
1、安装python
[root@C6 soft]# ls
ipython-1.2.1.tar.gz Python-2.7.13.tgz
[root@C6 soft]# tar xf Python-2.7.13.tgz
[root@C6 soft]# ls
ipython-1.2.1.tar.gz Python-2.7.13 Python-2.7.13.tgz
[root@C6 soft]# cd Python-2.7.13
#configure文件
[root@C6 Python-2.7.13]# ./configure --help
`configure' configures python 2.7 to adapt to many kinds of systems.
Usage: ./configure [OPTION]... [VAR=VALUE]...
#在安装前要先安装所需环境
[root@C6 Python-2.7.13]# yum install readline-devel -y
[root@C6 Python-2.7.13]# yum groupinstall -y "Development Tools"
#安装到指定路径下
[root@C6 Python-2.7.13]# ./configure --prefix=/usr/local/python27
[root@C6 Python-2.7.13]# echo $?
0
[root@C6 Python-2.7.13]# make && make installpython安装完成
[root@C6 Python-2.7.13]# /usr/local/python27/bin/python2.7
Python 2.7.13 (default, Feb 27 2017, 18:23:38)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-17)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> print "hello python"hello python2、安装ipython
[root@C6 ipython-1.2.1]# tar xf ipython-1.2.1.tar.gz
[root@C6 ipython-1.2.1]# cd ipython-1.2.1
[root@C6 ipython-1.2.1]# /usr/local/python27/bin/python2.7 setup.py build
[root@C6 ipython-1.2.1]# /usr/local/python27/bin/python2.7 setup.py install
[root@C6 ipython-1.2.1]# echo $?
0
[root@C6 ipython-1.2.1]# ls /usr/local/python27/bin/
2to3 iplogger pydoc python2-config
idle iptest python python-config
ipcluster ipython python2 smtpd.py
ipcontroller irunner python2.7 ipengine pycolor python2.7-config创建链接
[root@C6 ipython-1.2.1]# ln -sv /usr/local/python27/bin/python2.7 /usr/bin/python27
`/usr/bin/python27' -> `/usr/local/python27/bin/python2.7'
[root@C6 ipython-1.2.1]# ln -sv /usr/local/python27/bin/ipython /usr/bin/
`/usr/bin/ipython' -> `/usr/local/python27/bin/ipython'ipython安装完成
[root@C6 ~]# ipython
WARNING: IPython History requires SQLite, your history will not be saved
Python 2.7.13 (default, Feb 27 2017, 18:23:38)
Type "copyright", "credits" or "license" for more information.
IPython 1.2.1 -- An enhanced Interactive Python.?
-> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help -> Python's own help system.
object? -> Details about 'object', use 'object??' for extra details.
In [1]: print "hello world"
hello world