Linux下Python环境搭建

时间:2022-06-07 02:10:08

Linux下Python环境搭建

 

系统环境

OSOracle Linux Enterprise 5.6

 

1.下载

Python

地址: http://www.python.org/getit/

版本: Python-2.7.3.tgz

 

setuptools

地址:http://pypi.python.org/pypi/setuptools#downloads

版本:setuptools-0.6c11.tar.gz(md5)

也可以采用wget方式下载:

wget http://pypi.python.org/packages/source/s/setuptools/setuptools-0.6c11.tar.gz#md5=7df2a529a074f613b509fb44feefe74e

 

2.安装Python

--查看系统自带的python

[root@njdyw ~]# python

python       python2      python2.4

 

--安装Python2.7.3

[root@njdyw ~]# mkdir /python

[root@njdyw ~]# cp Python-2.7.3.tgz /python/

[root@njdyw ~]# cd /python/

[root@njdyw python]# ls

Python-2.7.3.tgz

 

--解压

[root@njdyw python]# tar -zvxf Python-2.7.3.tgz

[root@njdyw python]# ls

Python-2.7.3  Python-2.7.3.tgz

 

--configure:避免对原有的Python产生影响,必须制定prefix

[root@njdyw python]# cd Python-2.7.3

[root@njdyw Python-2.7.3]# ./configure --prefix=/usr/local/python2.7.3

 

--make:

[root@njdyw Python-2.7.3]# make

 

--make install:

[root@njdyw Python-2.7.3]# make install

 

安装成功后目录为:

[root@njdyw Python-2.7.3]# ll /usr/local/python2.7.3/

总计 16

drwxr-xr-x 2 root root 4096 03-21 10:12 bin

drwxr-xr-x 3 root root 4096 03-21 10:07 include

drwxr-xr-x 4 root root 4096 03-21 10:07 lib

drwxr-xr-x 3 root root 4096 03-21 10:07 share

 

--建立软链接:

[root@njdyw Python-2.7.3]# ln -s /usr/local/python2.7.3/bin/python /bin/python2.7.3

[root@njdyw Python-2.7.3]# python

python       python2      python2.4    python2.7.3 

[root@njdyw Python-2.7.3]# python2.7.3

Python 2.7.3 (default, Mar 21 2013, 10:06:48)

[GCC 4.1.2 20080704 (Red Hat 4.1.2-50)] on linux2

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

>>> print 1

1

>>>

 

3.安装setuptools

 

--使用wget下载:

[root@njdyw python]# pwd

/python

[root@njdyw python]#wget http://pypi.python.org/packages/source/s/setuptools/setuptools-0.6c11.tar.gz#md5=7df2a529a074f613b509fb44feefe74e

[root@njdyw python]# ls

Python-2.7.3  Python-2.7.3.tgz  setuptools-0.6c11.tar.gz

 

 

--解压:

[root@njdyw python]# tar xzvf setuptools-0.6c11.tar.gz

[root@njdyw python]# ls

Python-2.7.3  Python-2.7.3.tgz  setuptools-0.6c11  setuptools-0.6c11.tar.gz

 

--安装:

[root@njdyw setuptools-0.6c11]# python2.7.3 setup.py install

 

 

--建立软链接:

[root@njdyw setuptools-0.6c11]#ln -s /usr/local/python2.7.3/bin/easy_install /bin/easy_install2.7.3

 

4.测试使用easy_install

[root@njdyw setuptools-0.6c11]# easy_install2.7.3 numpy

 

 

 参考:

http://f.dataguru.cn/forum.php?mod=viewthread&tid=36405&fromuid=4771