工大后院

 找回密码
 加入后院

扫一扫,访问微社区

QQ登录

只需一步,快速开始

搜索
查看: 520|回复: 0

Linux配置Python环境的方法

[复制链接]
发表于 2015-4-2 21:03 | 显示全部楼层 |阅读模式

2 ]6 F) G. R8 D' T' E& h$ J& ~    在Linux上想要使用Python,就需要对其环境进行相关配置,因为涉及的步骤比较多,所以小编就给大家做个详细讲解,下面就一起来看看Linux配置Python环境的方法吧。
. c' q; L. z& ?# W    OS:Oracle Linux Enterprise 5.6
- }  k* c* A) S. k# l* i4 W  `! ^  1.下载* [- L5 g; c! I% ^8 r7 W+ G
  Python0 }2 _0 u; Z" P+ s# H/ z
  版本: Python-2.7.3.tgz
' Z/ ~! I' l1 ^5 ~5 H# ^' S6 E  setuptools" S) J8 H) w# ]# T' n5 h7 O
  版本:setuptools-0.6c11.tar.gz(md5)
: M0 `; f9 E* |6 y2 f8 B6 s  也可以采用wget方式下载:
& J& V6 g, y1 \% C$ |4 {4 x' C  wget pypi.python.org/packages/source/s/setuptools/setuptools-0.6c11.tar.gz#md5=7df2a529a074f613b509fb44feefe74e
" F! b- n- h6 P8 X: I  2.安装Python
3 w" ]* v  y$ W+ o  --查看系统自带的python:
! b* C: Q. T5 @, E- t+ N9 e  [root@njdyw ~]# python# p2 q, n. l! S( D; h+ ^- i
  python python2 python2.4# j: a% {4 C+ u  D
  --安装Python2.7.3- G( f3 K  z1 _7 |! {3 i
  [root@njdyw ~]# mkdir /python0 E4 Y& }! `: x5 E% P
  [root@njdyw ~]# cp Python-2.7.3.tgz /python/
$ Z- f2 h- ?5 P. G, A  [root@njdyw ~]# cd /python/( z6 Z, V: J; h6 J& r  L
  [root@njdyw python]# ls3 D9 x% H" D5 l: }! x# P
  Python-2.7.3.tgz
( g5 |3 v1 P( f  --解压1 }# e9 v' ~7 ]
  [root@njdyw python]# tar -zvxf Python-2.7.3.tgz
. m3 L$ H5 @; P. ~: q( r% o  [root@njdyw python]# ls1 ~4 d6 i+ U# Q4 U
  Python-2.7.3 Python-2.7.3.tgz' {0 L# e6 F% Z: T) j8 ~
  --configure:避免对原有的Python产生影响,必须制定prefix。# I: T4 h) f5 p2 A. P# T* d
  [root@njdyw python]# cd Python-2.7.3' y2 v" t' w0 b( j+ k& e& r
  [root@njdyw Python-2.7.3]# 。/configure --prefix=/usr/local/python2.7.3; }7 L2 P- k0 {
  --make:
) o  T4 ?7 F# i1 G7 v0 m/ \  [root@njdyw Python-2.7.3]# make% f: J; }. [9 N0 S' H4 i
  --make install:# D/ ?' o4 X2 R4 W8 Z
  [root@njdyw Python-2.7.3]# make install  A! ?6 K; K$ [# D5 H4 M2 \/ g
    安装成功后目录为:
' a7 C/ G2 Q9 t' ~# _  [root@njdyw Python-2.7.3]# ll /usr/local/python2.7.3/
7 I# f: A1 t) K0 Y. `/ X/ V  ^  总计 16; T" w/ Q" o: K- c7 F
  drwxr-xr-x 2 root root 4096 03-21 10:12 bin: D: }; O5 `) ]% k0 E6 ^& n
  drwxr-xr-x 3 root root 4096 03-21 10:07 include: O7 R! Q! V# u/ d( v9 b
  drwxr-xr-x 4 root root 4096 03-21 10:07 lib1 I# \- a" B) }; A2 i6 c9 n5 O* e
  drwxr-xr-x 3 root root 4096 03-21 10:07 share/ R  W# a1 C) C3 x- H4 Q% J
  --建立软链接:: S( q  [- ^6 @/ y. z1 E
  [root@njdyw Python-2.7.3]# ln -s /usr/local/python2.7.3/bin/python /bin/python2.7.3
! L/ f- \- _8 J8 n5 q6 t  [root@njdyw Python-2.7.3]# python0 M- X: g* h5 j) n
  python python2 python2.4 python2.7.3  T2 @$ |- F: {6 B/ }, z3 ~
  [root@njdyw Python-2.7.3]# python2.7.3; l( z. R0 T0 K6 i' ^
  Python 2.7.3 (default, Mar 21 2013, 10:06:48)% z" x9 [2 u* a2 e" {( w" k
  [GCC 4.1.2 20080704 (Red Hat 4.1.2-50)] on linux2
3 R# |4 Q% A7 A" A! O! ~$ k  Type “help”, “copyright”, “credits” or “license” for more information.6 e: P! J" o. ?
  3.安装setuptools
' k1 o$ T$ b( h5 O% X  --使用wget下载:4 `1 m- k1 V+ c4 h
  [root@njdyw python]# pwd6 d6 G) W, A, q& f! U- G
  /python
% a& w$ t! c6 y. h0 A4 v+ }  [root@njdyw python]#wget pypi.python.org/packages/source/s/setuptools/setuptools-0.6c11.tar.gz#md5=7df2a529a074f613b509fb44feefe74e
. |8 Z: D1 l9 n9 J  [root@njdyw python]# ls
; b8 X, g/ t: q/ h  Python-2.7.3 Python-2.7.3.tgz setuptools-0.6c11.tar.gz
/ y$ E5 o0 i( T* T# X7 w- |) U  --解压:
6 Z" R" c+ N% l0 w+ z# J$ F8 _# M8 V  [root@njdyw python]# tar xzvf setuptools-0.6c11.tar.gz
1 \! N2 F3 ?' A" Z1 m& y! \" v  [root@njdyw python]# ls- j+ q: \4 v/ u, g
  Python-2.7.3 Python-2.7.3.tgz setuptools-0.6c11 setuptools-0.6c11.tar.gz
( X' R. a! E9 X6 M( H6 {. b+ V; E$ Z  --安装:8 s7 C! J% Y$ L: e4 ^
  [root@njdyw setuptools-0.6c11]# python2.7.3 setup.py install
# d( |: Q9 l' i( a* `  --建立软链接:8 i  O6 y* ]8 J) \  ]
  [root@njdyw setuptools-0.6c11]#ln -s /usr/local/python2.7.3/bin/easy_install /bin/easy_install2.7.37 P8 W  S/ D( n
  4.测试使用easy_install
& G  _! W0 o; C- `5 H) U  f  [root@njdyw setuptools-0.6c11]# easy_install2.7.3 numpy5 t0 N$ G& P/ i& I- @' ~& r8 A
  上面就是Linux配置Python环境的方法介绍了,宏基笔记本系统cjghost.com/soft_list/2_21-1.html本文是以Oracle为例子做了讲解,安装完Python后需要安装setuptools。
您需要登录后才可以回帖 登录 | 加入后院

本版积分规则

QQ|Archiver|手机版|小黑屋|广告业务Q|工大后院 ( 粤ICP备10013660号 )

GMT+8, 2025-9-26 05:58

Powered by Discuz! X3.5

Copyright © 2001-2024 Tencent Cloud.

快速回复 返回顶部 返回列表