Q132284591 发表于 2017-4-20 12:36:27

python升级

1# python2Python 2.4.3 (#1, May 5 2011, 16:39:10)
3 on linux2
4Type "help", "copyright", "credits" or "license" for more information.
5>;>>
6#
下载新版本的python1# wget http://python.org/ftp/python/2.7.2/Python-2.7.2.tgz



解压缩 以及编译
01# tar xvf Python-2.7.2.tar.bz2
02# ./configure --prefix=/usr/local/python27
03# make
04# make install
05# ls /usr/local/python27/ -al
06total 28
07drwxr-xr-x 6 root root 4096 Jul 14 00:21 .
08drwxr-xr-x 20 root root 4096 Jul 14 00:17 ..
09drwxr-xr-x 2 root root 4096 Jul 14 00:21 bin
10drwxr-xr-x 3 root root 4096 Jul 14 00:21 include
11drwxr-xr-x 4 root root 4096 Jul 14 00:21 lib
12drwxr-xr-x 3 root root 4096 Jul 14 00:21 share



覆盖原来的python链接1# mv /usr/bin/python /usr/bin/python_old
2# ln -s /usr/local/python27/bin/python /usr/bin/
3# python
4Python 2.7.2 (default, Jul 14 2011, 00:20:14)
5 on linux2
6Type "help", "copyright", "credits" or "license" for more information.
7>>>



此处已经可以正常使用python2.7了
但是因为yum是使用的2.4的版本来用的,现在输入一下yum就会报错01# yum
02There was a problem importing one of the Python modules
03required to run yum. The error leading to this problem was:
04 
05No module named yum
06 
07Please install a package which provides this module, or
08verify that the module is installed correctly.
09 
10It's possible that the above module doesn't match the
11current version of Python, which is:
122.7.2 (default, Jul 14 2011, 00:20:14)
13
14 
15If you cannot solve this problem yourself, please go to
16the yum faq at:
17http://wiki.linux.duke.edu/YumFaq


所以还需要修改一下01# vim /usr/bin/yum
02 
03#!/usr/bin/python #修改此处为2.4的位置
04# vim /usr/bin/yum
05 
06#!/usr/bin/python2.4
07# yum
08Loaded plugins: fastestmirror
09You need to give some command
10usage: yum COMMAND
11 
12List of Commands:
13 
14check-update Check for available package updates
15clean Remove cached data
16deplist List a package's dependencies
17downgrade downgrade a package
18erase Remove a package or packages from your system
19groupinfo Display details about a package group
20groupinstall Install the packages in a group on your system
21grouplist List available package groups
22groupremove Remove the packages in a group from your system
23help Display a helpful usage message
24info Display details about a package or group of packages
25install Install a package or packages on your system
26list List a package or groups of packages
27localinstall Install a local RPM



  yum 又可以使用了
  http://heylinux.com/en/?p=167
页: [1]
查看完整版本: python升级