zoukankan      html  css  js  c++  java
  • python install (version problem-method ln -s)

    一般情况下,无需自己安装Python。因为在大多数Linux版本中,如Fedora,Ubuntu等,都已经默认安装了Python,但也可以根据需要自定义安装Python。下面使用源码编译安装来举个例子。

      1. 下载源码包。http://www.python.org/getit/

      2. 总体概要:
      3.        $ tar –jxvf Python-2.5.2.tar.bz2
               $ cd Python-2.5.2
               $ ./configure
               $ make
               $ make install
      4. 解压安装包。在终端进入压缩包所在目录,输入命令tar -zxvf Python-2.5.2.tgz (or bzcat Python-2.5.2.tar.bz2 | tar -xf -),即可完成解压过程。
      5. 进入解压后的python目录,一般先看一下安装说明README,这里详细讲述了Python 2.5.2的相关资源及其网址和各种支持的操作系统下的安装方法。读者可以根据需求适当参考该文档。下面给出Python最普通的安装过程。
      6. ./configure,进行配置。这里有个最常设置的选项是prefix,默认值为/usr/local/lib,设置该选项来指定python的安装目录,即./configure --prefix=/home/shengyan/python2.5.2。
      7. make,编译源码。若这边没出现什么错误即可进入下一步,若有错误的话,则可能有很多原因,比如当前系统缺少某些所需程序或者尚未解决某些依赖关系,这样的话得一步一步找出错误直至解决,才能编译正确。
      8. make install,真正安装。注意,若这里出现权限限制的话,则表明当前用户没有足够权限将Python程序文档文件写入指定的目录,比如说/usr /local/lib等系统目录,这样的话,需要sudo make install,输入密码后即可进行。因为之前设置了prefix为自己用户下的目录,所以直接make install就ok了。等待一段时间后,若没有错误提示就表明已经成功安装Python2.5.2。
      9. 成功安装后,在 /home/shengyan/python2.5.2下就是刚刚安装的Python目录。在终端中进入/home/shengyan /python2.5.2目录,输入./python,即可进入Python交互环境,可以看到刚才安装的Python2.5.2。
      10. 若想在终端中直接输入python,启动的是Python2.5.2,而不是以前的旧版本,则应该做以下两个方法:
        • 方 法一,修改环境变量PATH。若仅仅在终端下修改PATH,只对当前终端有效。若想在其他终端中或重启之后还有效的话,则需在用户目录的.bashrc文 件末尾加入export PATH=/home/shengyan/python2.5/bin:$PATH,注销或重启X就可。具体设置PATH的多种方法可参考这里

        • 方法二,上述方法仅对当前用户环境进行设置,若想在系统上,全局使用Python2.5.2,则需以下步骤:测试
                 在命令行下输入python,出现python解释器即表示已经正确安装。
          在suse10或rhel5(es5)下系统默认已经装了python但版本是2.4.x;本次安装后在shell中输入
          #python
          会发现显示结果:
          # python
          Python 2.4.3 (#1, Dec 11 2006, 11:38:52)
          [GCC 4.1.1 20061130 (Red Hat 4.1.1-43)] on linux2
          Type "help", "copyright", "credits" or "license" for more information.
          >>>
          版本还是2.4.x的
          解决办法:
                  #cd /usr/bin
                  #ll |grep python   //查看该目录下python
                  #rm -rf python
                  #ln -s PREFIX/Python-2.5.2/python ./python  //PREFIX为你解压python的目录
                          #python
                         
                                # python
                                   Python 2.5.2 (#1, Dec 11 2006, 11:38:52)
                                   [GCC 4.1.1 20061130 (Red Hat 4.1.1-43)] on linux2
                                  Type "help", "copyright", "credits" or "license" for more information.
                                   >>>
          OK!问题解决!
  • 相关阅读:
    周末之个人杂想(十三)
    PowerTip of the DaySorting Multiple Properties
    PowerTip of the DayCreate Remoting Solutions
    PowerTip of the DayAdd Help to Your Functions
    PowerTip of the DayAcessing Function Parameters by Type
    PowerTip of the DayReplace Text in Files
    PowerTip of the DayAdding Extra Information
    PowerTip of the DayPrinting Results
    Win7下IIS 7.5配置SSAS(2008)远程访问
    PowerTip of the DayOpening Current Folder in Explorer
  • 原文地址:https://www.cnblogs.com/eiguleo/p/4291213.html
Copyright © 2011-2022 走看看