zoukankan      html  css  js  c++  java
  • 教为学:python学习之路(一):python源码安装

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

    前言

    Python是一门万金油语言,特别在Linux下。一般的Linux系统也自带Python。不过,我们依旧有必要学习怎么在Linux下安装Python。

    操作系统的版本:

    1. gaopeng@gaopeng-virtual-machine:~$ uname -a
    2. 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版本:

    1. gaopeng@gaopeng-virtual-machine:~$ python
    2. Python 2.7.3 (default, Aug 1 2012, 05:16:07)

    安装配置Python

    本质上Linux下软件安装的步骤是一致的。所以,我们在这里也不做过多的解释,直接运行,看效果。

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

    解压Python安装包。

    1. gaopeng@gaopeng-virtual-machine:~/python$ tar -zxvf Python-2.7.5.tgz
    2. gaopeng@gaopeng-virtual-machine:~/python$ ls
    3. Python-2.7.5 Python-2.7.5.tgz

    经典的安装三部曲。

    1. gaopeng@gaopeng-virtual-machine:~$ cd python/Python-2.7.5/
    2. gaopeng@gaopeng-virtual-machine:~/python/Python-2.7.5$sudo ./configure --prefix=/usr/local/python2.7.5
    3. gaopeng@gaopeng-virtual-machine:~/python/Python-2.7.5$ sudo make
    4. gaopeng@gaopeng-virtual-machine:~/python/Python-2.7.5$ sudo make install

    --prefix=/usr/local/python2.7.5的意思是指定当前程序的安装目录。

    为了避免冲突,我们接下来进行软连接。

    1. gaopeng@gaopeng-virtual-machine:~/python/Python-2.7.5$ sudo ln -s /bin/local/python2.7.5/bin/python /bin/python2.7.5

    EasyInstall 的源码安装

    首先的先下载源码包。

    1. gaopeng@gaopeng-virtual-machine:~/python$ wget https://pypi.python.org/packages/source/s/setuptools/setuptools-0.6c11.tar.gz#md5=7df2a529a074f613b509fb44feefe74e

    解压源码包。

    1. gaopeng@gaopeng-virtual-machine:~/python$ tar -zxvf setuptools-0.6c11.tar.gz

    build和install。

    1. gaopeng@gaopeng-virtual-machine:~/python$ cd setuptools-0.6c11/
    2. gaopeng@gaopeng-virtual-machine:~/python/setuptools-0.6c11$ sudo python2.7.5 setup.py build
    3. gaopeng@gaopeng-virtual-machine:~/python/setuptools-0.6c11$ sudo python2.7.5 setup.py install

    同样建立软连接。

    1. gaopeng@gaopeng-virtual-machine:~/python/Python-2.7.5$ sudo ln -s /bin/local/python2.7.5/bin/easy_install /bin/ey2.7.5
    我坚信初学者更习资料是自己亲手记录。
    我坚信最好的加明白初学者学习的困难在哪里。
    我坚信最好的学学习方法是自己动手。
    我坚信最好的检验方式就是能把自己所学到的东西转手教给别人。
                                     -----作者: 高鹏
  • 相关阅读:
    欧拉函数
    新博客地址
    socket编程
    文件操作
    python安装扩展”unable to find vcvarsall.bat“的解决办法
    PYTHON以及插件安装
    梯式结构
    PHPSTORM配置
    CSRF攻击
    js的一些奇葩用法
  • 原文地址:https://www.cnblogs.com/jiaoweixue/p/3098701.html
Copyright © 2011-2022 走看看