python2.4升级2.7.2入门实例
发布时间:2020-12-17 07:16:45 所属栏目:Python 来源:网络整理
导读:对python这个高级语言感兴趣的小伙伴,下面一起跟随编程之家 jb51.cc的小编两巴掌来看看吧! [root@~]# python Python 2.4.3 (#1,May 5 2011,16:39:10) [GCC 4.1.2 20080704 (Red Hat 4.1.2-50)] on linux2 Type help,copyright,credits or license for more
对python这个高级语言感兴趣的小伙伴,下面一起跟随编程之家 52php.cn的小编两巴掌来看看吧!
[root@~]# python
Python 2.4.3 (#1,May 5 2011,16:39:10) [GCC 4.1.2 20080704 (Red Hat 4.1.2-50)] on linux2 Type "help","copyright","credits" or "license" for more information. >;>> [root@~]# 下载新版本的python [root@~]# wget
解压缩 以及编译 [root@~]# tar jxvf Python-2.7.3.tar.bz2
[root@wangyuelou Python-2.7.2]# ./configure --prefix=/usr/local/python27 [root@wangyuelou Python-2.7.2]# make [root@wangyuelou Python-2.7.2]# make install [root@wangyuelou Python-2.7.2]# ls /usr/local/python27/ -al total 28 drwxr-xr-x 6 root root 4096 Jul 14 00:21 . drwxr-xr-x 20 root root 4096 Jul 14 00:17 .. drwxr-xr-x 2 root root 4096 Jul 14 00:21 bin drwxr-xr-x 3 root root 4096 Jul 14 00:21 include drwxr-xr-x 4 root root 4096 Jul 14 00:21 lib drwxr-xr-x 3 root root 4096 Jul 14 00:21 share 覆盖原来的python链接 [root@wangyuelou Python-2.7.2]# mv /usr/bin/python /usr/bin/python_old
[root@wangyuelou Python-2.7.2]# ln -s /usr/local/python27/bin/python /usr/bin/ [root@wangyuelou Python-2.7.2]# python Python 2.7.2 (default,Jul 14 2011,00:20:14) [GCC 4.1.2 20080704 (Red Hat 4.1.2-50)] on linux2 Type "help","credits" or "license" for more information. >>> 此处已经可以正常使用python2.7了 但是因为yum是使用的2.4的版本来用的,所以 还需要修改一下 [root@~]# yum
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.2 (default,00:20:14) [GCC 4.1.2 20080704 (Red Hat 4.1.2-50)] If you cannot solve this problem yourself,please go to the yum faq at: [root@wangyuelou Python-2.7.2]# vim /usr/bin/yum #!/usr/bin/python #修改此处为2.4的位置 [root@~]# vim /usr/bin/yum #!/usr/bin/python2.4 [root@~]# yum Loaded plugins: fastestmirror You need to give some command usage: yum [options] COMMAND List of Commands: check-update Check for available package updates clean Remove cached data deplist List a package's dependencies downgrade downgrade a package erase Remove a package or packages from your system groupinfo Display details about a package group groupinstall Install the packages in a group on your system grouplist List available package groups groupremove Remove the packages in a group from your system help Display a helpful usage message info Display details about a package or group of packages install Install a package or packages on your system list List a package or groups of packages localinstall Install a local RPM yum 又可以使用了) # Process the JSON string. results = simplejson.load(response) # now have some fun with the results... 实际应用中可能需要抓取google的很多网页,所以还需要使用多线程来分担抓取任务。使用google web search api的参考详细介绍,请看此处(这里介绍了Standard URL Arguments)。另外要特别注意,url中参数rsz必须是8(包括8)以下的值,若大于8,会报错的! (3)代码实现 代码实现还存在问题,但是能够运行,鲁棒性差,还需要进行改进,希望各路大神指出错误(初学Python),不胜感激。 python代码如下: (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |