升级Python,只需要简单的几步:
查看系统当前python版本
123[root@localhost ~]# python -VPython 2.6.6[root@localhost ~]#下载新版本的python2.7
1[root@localhost ~]# wget http://python.org/ftp/python/2.7.2/Python-2.7.2.tgz
- 解压缩以及编译
|
|
- 覆盖原来的python链接1234[root@localhost Python-2.7.2]# mv /usr/bin/python /usr/bin/python_old[root@localhost Python-2.7.2]# ln -s /usr/local/python27/bin/python /usr/bin/[root@localhost Python-2.7.2]# python -VPython 2.7.2
此时已经可以正常使用python2.7了。
但是因为yum是使用的2.6的版本来用的,所以 还需要修改一下。
修改yum使用的Python版本
1234567891011121314151617[root@localhost Python-2.7.2]# yumThere was a problem importing one of the Python modulesrequired to run yum. The error leading to this problem was:No module named yumPlease install a package which provides this module, orverify that the module is installed correctly.It's possible that the above module doesn't match thecurrent version of Python, which is:2.7.2 (default, Jan 15 2016, 12:40:26)[GCC 4.4.7 20120313 (Red Hat 4.4.7-16)]If you cannot solve this problem yourself, please go tothe yum faq at:http://yum.baseurl.org/wiki/Faq[root@localhost Python-2.7.2]# vim /usr/bin/yum#!/usr/bin/python #修改此处为2.6的位置[root@localhost Python-2.7.2]# vim /usr/bin/yum#!/usr/bin/python2.6检查yum
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576[root@localhost Python-2.7.2]# yumLoaded plugins: fastestmirror, securityYou need to give some commandUsage: yum [options] COMMANDList of Commands:check Check for problems in the rpmdbcheck-update Check for available package updatesclean Remove cached datadeplist List a package's dependenciesdistribution-synchronization Synchronize installed packages to the latest available versionsdowngrade downgrade a packageerase Remove a package or packages from your systemgroupinfo Display details about a package groupgroupinstall Install the packages in a group on your systemgrouplist List available package groupsgroupremove Remove the packages in a group from your systemhelp Display a helpful usage messagehistory Display, or use, the transaction historyinfo Display details about a package or group of packagesinstall Install a package or packages on your systemlist List a package or groups of packagesload-transaction load a saved transaction from filenamemakecache Generate the metadata cacheprovides Find what package provides the given valuereinstall reinstall a packagerepolist Display the configured software repositoriesresolvedep Determine which package provides the given dependencysearch Search package details for the given stringshell Run an interactive yum shellupdate Update a package or packages on your systemupdate-minimal Works like update, but goes to the 'newest' package match which fixes a problem that affects your systemupdateinfo Acts on repository update informationupgrade Update packages taking obsoletes into accountversion Display a version for the machine and/or available repos.Options:-h, --help show this help message and exit-t, --tolerant be tolerant of errors-C, --cacheonly run entirely from system cache, don't update cache-c [config file], --config=[config file]config file location-R [minutes], --randomwait=[minutes]maximum command wait time-d [debug level], --debuglevel=[debug level]debugging output level--showduplicates show duplicates, in repos, in list/search commands-e [error level], --errorlevel=[error level]error output level--rpmverbosity=[debug level name]debugging output level for rpm-q, --quiet quiet operation-v, --verbose verbose operation-y, --assumeyes answer yes for all questions--version show Yum version and exit--installroot=[path] set install root--enablerepo=[repo] enable one or more repositories (wildcards allowed)--disablerepo=[repo] disable one or more repositories (wildcards allowed)-x [package], --exclude=[package]exclude package(s) by name or glob--disableexcludes=[repo]disable exclude from main, for a repo or for everything--obsoletes enable obsoletes processing during updates--noplugins disable Yum plugins--nogpgcheck disable gpg signature checking--disableplugin=[plugin] disable plugins by name--enableplugin=[plugin] enable plugins by name--skip-broken skip packages with depsolving problems--color=COLOR control whether color is used--releasever=RELEASEVER set value of $releasever in yum config and repo files--setopt=SETOPTS set arbitrary config and repo optionsPlugin Options:--security Include security relevant packages--bugfixes Include bugfix relevant packages--cve=CVE Include packages needed to fix the given CVE--bz=BZ Include packages needed to fix the given BZ--sec-severity=SEVERITY Include security relevant packages, of this severity--advisory=ADVISORY Include packages needed to fix the given advisory
yum 又可以使用了