您现在的位置: 万盛学电脑网 >> 操作系统 >> Linux教程 >> 正文

Linux配置Python环境的方法

作者:佚名    责任编辑:admin    更新时间:2022-06-22

  在Linux上想要使用Python,就需要对其环境进行相关配置,因为涉及的步骤比较多,所以小编就给大家做个详细讲解,下面就一起来看看Linux配置Python环境的方法吧。

 Linux配置Python环境的方法

  OS:Oracle Linux Enterprise 5.6

  1.下载

  Python

  版本: Python-2.7.3.tgz

  setuptools

  版本: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

上一页12下一页共2页

  安装成功后目录为:

  [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.

  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

  上面就是Linux配置Python环境的方法介绍了,本文是以Oracle为例子做了讲解,安装完Python后需要安装setuptools。

上一页12 下一页共2页