1 |
[root@local_redhat ~] # python |
2 |
Python 2.4.3 ( #1, May 5 2011, 16:39:10) |
3 |
[GCC 4.1.2 20080704 (Red Hat 4.1.2-50)] on linux2 |
4 |
Type "help" , "copyright" , "credits" or "license" for more information. |
5 |
>;>> |
6 |
[root@local_redhat ~] # |
下载新版本的python
1 |
[root@local_redhat ~] # wget http://python.org/ftp/python/2.7.2/Python-2.7.2.tgz |
解压缩 以及编译
01 |
[root@local_redhat ~] # tar xvf Python-2.7.2.tar.bz2 |
02 |
[root@local_redhat Python-2.7.2] # ./configure --prefix=/usr/local/python27 |
03 |
[root@local_redhat Python-2.7.2] # make |
04 |
[root@local_redhat Python-2.7.2] # make install |
05 |
[root@local_redhat Python-2.7.2] # ls /usr/local/python27/ -al |
06 |
total 28 |
07 |
drwxr-xr-x 6 root root 4096 Jul 14 00:21 . |
08 |
drwxr-xr-x 20 root root 4096 Jul 14 00:17 .. |
09 |
drwxr-xr-x 2 root root 4096 Jul 14 00:21 bin |
10 |
drwxr-xr-x 3 root root 4096 Jul 14 00:21 include |
11 |
drwxr-xr-x 4 root root 4096 Jul 14 00:21 lib |
12 |
drwxr-xr-x 3 root root 4096 Jul 14 00:21 share |
覆盖原来的python链接
1 |
[root@local_redhat Python-2.7.2] # mv /usr/bin/python /usr/bin/python_old |
2 |
[root@local_redhat Python-2.7.2] # ln -s /usr/local/python27/bin/python /usr/bin/ |
3 |
[root@local_redhat Python-2.7.2] # python |
4 |
Python 2.7.2 (default, Jul 14 2011, 00:20:14) |
5 |
[GCC 4.1.2 20080704 (Red Hat 4.1.2-50)] on linux2 |
6 |
Type "help" , "copyright" , "credits" or "license" for more information. |
7 |
>>> |
此处已经可以正常使用python2.7了
但是因为yum是使用的2.4的版本来用的,现在输入一下yum就会报错
所以还需要修改一下
01 |
[root@local_redhat ~] # yum |
02 |
There was a problem importing one of the Python modules |
03 |
required to run yum. The error leading to this problem was: |
04 |
05 |
No module named yum |
06 |
07 |
Please install a package which provides this module, or |
08 |
verify that the module is installed correctly. |
09 |
10 |
It 's possible that the above module doesn' t match the |
11 |
current version of Python, which is: |
12 |
2.7.2 (default, Jul 14 2011, 00:20:14) |
13 |
[GCC 4.1.2 20080704 (Red Hat 4.1.2-50)] |
14 |
15 |
If you cannot solve this problem yourself, please go to |
16 |
the yum faq at: |
17 |
http://wiki.linux.duke.edu/YumFaq |
01 |
[root@local_redhat Python-2.7.2] # vim /usr/bin/yum |
02 |
03 |
#!/usr/bin/python #修改此处为2.4的位置 |
04 |
[root@local_redhat ~] # vim /usr/bin/yum |
05 |
06 |
#!/usr/bin/python2.4 |
07 |
[root@local_redhat ~] # yum |
08 |
Loaded plugins: fastestmirror |
09 |
You need to give some command |
10 |
usage: yum [options] COMMAND |
11 |
12 |
List of Commands: |
13 |
14 |
check-update Check for available package updates |
15 |
clean Remove cached data |
16 |
deplist List a package's dependencies |
17 |
downgrade downgrade a package |
18 |
erase Remove a package or packages from your system |
19 |
groupinfo Display details about a package group |
20 |
groupinstall Install the packages in a group on your system |
21 |
grouplist List available package groups |
22 |
groupremove Remove the packages in a group from your system |
23 |
help Display a helpful usage message |
24 |
info Display details about a package or group of packages |
25 |
install Install a package or packages on your system |
26 |
list List a package or groups of packages |
27 |
localinstall Install a local RPM |
yum 又可以使用了