zoukankan      html  css  js  c++  java
  • Python2.7安装教程

      作者:zhanhailiang 日期:2014-11-16
    [root@~/software]# yum install bzip*
    [root@~/software]# wget http://www.python.org/ftp/python/2.7.3/Python-2.7.3.tgz
    [root@~/software]# tar zxvf Python-2.7.3.tgz
    [root@~/software]# cd Python-2.7.3
    [root@~/software/Python-2.7.3]# ./configure
    [root@~/software/Python-2.7.3]# make && make install
    [root@~/software]# cd /usr/local/bin/
    [root@/usr/local/bin]# ls -al python*
    lrwxrwxrwx 1 root root       7 Nov 16 18:24 python -> python2
    lrwxrwxrwx 1 root root       9 Nov 16 18:24 python2 -> python2.7
    -rwxr-xr-x 1 root root 6162217 Nov 16 18:23 python2.7
    -rwxr-xr-x 1 root root    1624 Nov 16 18:24 python2.7-config
    lrwxrwxrwx 1 root root      16 Nov 16 18:24 python2-config -> python2.7-config
    lrwxrwxrwx 1 root root      14 Nov 16 18:24 python-config -> python2-config
    [root@/usr/local/bin]# /usr/local/bin/python -V
    Python 2.7.3

    如此安装就完毕了。可是由于部分软件,如node.js依赖python2.7,此时须要改动系统路径python命令指向2.7.3版本号:

    [root@/usr/local/bin]# cp /usr/bin/python /usr/bin/python.bak.2014.11.16
    [root@/usr/local/bin]# rm /usr/bin/python
    [root@/usr/local/bin]# ln -s /usr/local/bin/python2.7 /usr/bin/python

    如此,假设遇到yum出问题。例如以下“There was a problem importing one of the Python modules”:

    [root@~/software/Python-2.7.3]# yum search bzip
    There was a problem importing one of the Python modules
    required to run yum. The error leading to this problem was:
     
       No module named yum
     
    Please install a package which provides this module, or
    verify that the module is installed correctly.
     
    It's possible that the above module doesn't match the
    current version of Python, which is:
    2.7.3 (default, Nov 16 2014, 18:22:57) 
    [GCC 4.4.7 20120313 (Red Hat 4.4.7-4)]
     
    If you cannot solve this problem yourself, please go to 
    the yum faq at:
      http://yum.baseurl.org/wiki/Faq

    这是由于yum依赖老版本号的python,能够按例如以下操作修复:

    [root@~/software/Python-2.7.3]# vim /usr/bin/yum

    改动第一行命令行,将python指向指定版本号即可了:

      1 #!/usr/bin/python2.6
      2 import sys
      3 try:
      4     import yum

    參考文章:http://www.tomtalk.net/wiki/Python

  • 相关阅读:
    11111 Generalized Matrioshkas
    Uva 442 Matrix Chain Multiplication
    Uva 10815 Andy's First Dictionary
    Uva 537 Artificial Intelligence?
    Uva 340 MasterMind Hints
    SCAU 9508 诸葛给我牌(水泥题)
    Uva 10420 List of Conquests(排序水题)
    Uva 409 Excuses, Excuses!
    10/26
    11/2
  • 原文地址:https://www.cnblogs.com/blfbuaa/p/6809394.html
Copyright © 2011-2022 走看看