美奇科技 发表于 2015-4-23 07:55:43

教为学:python学习之路(一):python源码安装

教为学:python学习之路(一):python源码安装
前言
  Python是一门万金油语言,特别在Linux下。一般的Linux系统也自带Python。不过,我们依旧有必要学习怎么在Linux下安装Python。
  操作系统的版本:

[*]
gaopeng@gaopeng-virtual-machine:~$ uname -a
[*]
Linux gaopeng-virtual-machine 3.2.0-38-generic #61-Ubuntu SMP Tue Feb 19 12:20:02 UTC 2013 i686 i686 i386 GNU/Linux
  系统自带python版本:

[*]
gaopeng@gaopeng-virtual-machine:~$ python
[*]
Python 2.7.3 (default, Aug 1 2012, 05:16:07)
安装配置Python
  本质上Linux下软件安装的步骤是一致的。所以,我们在这里也不做过多的解释,直接运行,看效果。

[*]
gaopeng@gaopeng-virtual-machine:~/python$ wget http://www.python.org/ftp/python/2.7.5/Python-2.7.5.tgz
[*]
--2013-05-21 17:06:40-- http://www.python.org/ftp/python/2.7.5/Python-2.7.5.tgz
[*]
正在解析主机 www.python.org (www.python.org)... 82.94.164.162, 2001:888:2000:d::a2
[*]
正在连接 www.python.org (www.python.org)|82.94.164.162|:80... 已连接。
[*]
已发出 HTTP 请求,正在等待回应... 200 OK
[*]
长度: 14492759 (14M)
[*]
正在保存至: "Python-2.7.5.tgz"
[*]
[*]
100%[======================================================>] 14,492,759 182K/s 用时 88s
[*]
[*]
2013-05-21 17:08:08 (162 KB/s) - 已保存 "Python-2.7.5.tgz" )
  解压Python安装包。

[*]
gaopeng@gaopeng-virtual-machine:~/python$ tar -zxvf Python-2.7.5.tgz
[*]
gaopeng@gaopeng-virtual-machine:~/python$ ls
[*]
Python-2.7.5 Python-2.7.5.tgz
  经典的安装三部曲。

[*]
gaopeng@gaopeng-virtual-machine:~$ cd python/Python-2.7.5/
[*]
gaopeng@gaopeng-virtual-machine:~/python/Python-2.7.5$sudo ./configure --prefix=/usr/local/python2.7.5
[*]
gaopeng@gaopeng-virtual-machine:~/python/Python-2.7.5$ sudo make
[*]
gaopeng@gaopeng-virtual-machine:~/python/Python-2.7.5$ sudo make install
  --prefix=/usr/local/python2.7.5的意思是指定当前程序的安装目录。
  为了避免冲突,我们接下来进行软连接。

[*]
gaopeng@gaopeng-virtual-machine:~/python/Python-2.7.5$ sudo ln -s /bin/local/python2.7.5/bin/python /bin/python2.7.5
EasyInstall 的源码安装
  首先的先下载源码包。

[*]
gaopeng@gaopeng-virtual-machine:~/python$ wget https://pypi.python.org/packages/source/s/setuptools/setuptools-0.6c11.tar.gz#md5=7df2a529a074f613b509fb44feefe74e
  解压源码包。

[*]
gaopeng@gaopeng-virtual-machine:~/python$ tar -zxvf setuptools-0.6c11.tar.gz
  build和install。

[*]
gaopeng@gaopeng-virtual-machine:~/python$ cd setuptools-0.6c11/
[*]
gaopeng@gaopeng-virtual-machine:~/python/setuptools-0.6c11$ sudo python2.7.5 setup.py build
[*]
gaopeng@gaopeng-virtual-machine:~/python/setuptools-0.6c11$ sudo python2.7.5 setup.py install
  同样建立软连接。

[*]
gaopeng@gaopeng-virtual-machine:~/python/Python-2.7.5$ sudo ln -s /bin/local/python2.7.5/bin/easy_install /bin/ey2.7.5
  
  
  
  
  
  
  
页: [1]
查看完整版本: 教为学:python学习之路(一):python源码安装