centos安装python2.7并安装easy_install,pip,ipython

时间:2022-10-28 02:03:22

1.安装python

下载python2.7.10

# wget https://www.python.org/ftp/python/2.7.10/Python-2.7.10.tgz

# tar -zxvf  Python-2.7.10.tgz

# cd  Python-2.7.10

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

# make && make install

然后测试python是否安装成功

# /usr/local/python/bin/python2.7

Python 2.7.10 (default, Aug 26 2015, 22:48:01)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-16)] on linux2
Type "help", "copyright", "credits" or "license" for more information.

建立软连接

# mv /usr/bin/python  /usr/bin/python26

# ln -s /usr/local/python/bin/python2.7  /usr/bin/python

因为升级python,会导致yum不可用,解决方法如下:

#vi /usr/bin/yum

将文件头行

#!/usr/bin/python

修改为
#!/usr/bin/python26
 
然后就成功了。

2.安装easy_install和pip

easy_install和pip都是用来下载安装Python一个公共资源库PyPI的相关资源包的

首先安装easy_install

# wget https://pypi.python.org/packages/source/e/ez_setup/ez_setup-0.9.tar.gz

# tar -zxvf ez_setup-0.9.tar.gz

# cd ez_setup-0.9

# python ez_setup.py

# ln -s /usr/local/python/bin/easy_install  /usr/bin/easy_install

安装好easy_install 之后 再安装pip

# wget https://pypi.python.org/packages/source/p/pip/pip-7.1.2.tar.gz

# tar -zxvf pip-7.1.2.tar.gz

# cd pip-7.1.2

# python setup.py install

# ln -s /usr/local/python/bin/pip  /usr/bin/pip

3.安装ipython

首先要装readline

# pip install readline

然后直接安装ipython

# pip install ipython

装上pip和easy_install,以后装任何模块都很轻松了