标签:python安装
一、准备安装环境
系统:centos 6.5
内核:
[root@test ~]# uname -r
2.6.32-431.el6.x86_64
二、下载相应软件包
python:wget http://www.python.org/ftp/python/2.7.3/Python-2.7.3.tgz
setuptools:wget https://pypi.python.org/packages/source/s/setuptools/setuptools-0.6c11.tar.gz#md5=7df2a529a074f613b509fb44feefe74e
三、开始实战安装
1)创建安装目录,并将下载的包放入此目录
[root@test /]# mkdir python
[root@test python]# ll
total 14068
-rw-r--r-- 1 root root 14135620 Apr 10 2012 Python-2.7.3.tgz
-rw-r--r-- 1 root root 256862 Nov 26 08:40 setuptools-0.6c11.tar.gz
[root@test python]# tar -zxvf Python-2.7.3.tgz
[root@test python]# ls
Python-2.7.3 Python-2.7.3.tgz
2)安装编译所需要的zlib,zlib-devel包(如果没有安装则出现如下错误
[root@test python]#yum -y install zlib zlib-devel
注:如果没有安装则出现如下错误
File "/usr/local/lib/python2.7/zipfile.py", line 681, in __init__
"Compression requires the (missing) zlib module"
RuntimeError: Compression requires the (missing) zlib module
3). 配置安装路径
[root@test Python-2.7.3]# ./configure --prefix=/usr/local/python-2.7.3
4). 编译和安装
[root@test Python-2.7.3]# make
[root@test Python-2.7.3]# make install
5). 配置软链接
[root@test /]# ln -s /usr/local/python-2.7.3/bin/python /bin/python-2.7.3
[root@test python]# python-2.7.3
Python 2.7.3 (default, Nov 26 2015, 08:51:08)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>
6). 下载安装setuptools
[root@test python]# tar -zxvf setuptools-0.6c11.tar.gz
[root@test python]# cd setuptools-0.6c11
[root@test setuptools-0.6c11]# python-2.7.3 setup.py build
[root@test setuptools-0.6c11]# python-2.7.3 setup.py install (这步很关键,如果出现了问题,请回到步骤2)安装依赖包,重新编译安装python即可)
[root@test bin]# ln -s /usr/local/python-2.7.3/bin/easy_install /bin/easy_install-2.7.3
7)利用easy_install安装相应库
[root@test setuptools-0.6c11]# easy_install-2.7.3 django
本文出自 “用心创造价值,晚点咖啡” 博客,请务必保留此出处http://wandiankafei.blog.51cto.com/10878910/1716959
标签:python安装
原文地址:http://wandiankafei.blog.51cto.com/10878910/1716959