免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 23243 | 回复: 9
打印 上一主题 下一主题

系统自带的python2.4有问题,想卸载重新安装新版本,执行python报错如下: [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2010-11-11 17:33 |只看该作者 |倒序浏览
系统自带的python2.4有问题,想卸载重新安装新版本,结果,安装新版本后,执行python报错如下:

# python
'import site' failed; use -v for tracebackPython 2.4.3 (#1, Sep  3 2009, 15:37:12)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-46)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>

在网上google,百度了一天,也没有结果,特来论坛请教高手指点!!~急,在线等等中。。。。。。。。

论坛徽章:
0
2 [报告]
发表于 2010-11-11 22:36 |只看该作者
不要卸载系统自带的,要不然你会很悲剧。一堆东西你都用不了。。

论坛徽章:
0
3 [报告]
发表于 2010-11-11 22:37 |只看该作者
建议独立安装新版,然后做个link过去,备份系统的即可。

论坛徽章:
2
2015年迎新春徽章
日期:2015-03-04 09:55:28IT运维版块每日发帖之星
日期:2016-07-29 06:20:00
4 [报告]
发表于 2010-11-12 08:10 |只看该作者
看提示,像缺少gcc相关的库文件。
1·yum安装python
2·再指定目录,编译安装新版本

论坛徽章:
0
5 [报告]
发表于 2010-11-12 11:17 |只看该作者
找到问题了原因了,问题已经解决,解决方法如下:

将原来好用的机器上的/usr/lib/python2.4整个目录拷贝到本机的相应路径下,同时,拷贝好用机器上的/usr/bin/python*到本机相应路径下。

#scp -r 192.168.1.2:/usr/lib/python2.4  /usr/lib/
#scp -r 192.168.1.2:/usr/bin/python*   /usr/bin/

# vi /etc/profile
添加环境变量
export PATH="/usr/bin/PATH"

#source /etc/profile

# python -v  重新导入
出现如下字样,即可正常:
# installing zipimport hook
import zipimport # builtin
# installed zipimport hook
# /usr/lib/python2.4/site.pyc matches /usr/lib/python2.4/site.py
import site # precompiled from /usr/lib/python2.4/site.pyc
# /usr/lib/python2.4/os.pyc matches /usr/lib/python2.4/os.py
import os # precompiled from /usr/lib/python2.4/os.pyc
import posix # builtin
# /usr/lib/python2.4/posixpath.pyc matches /usr/lib/python2.4/posixpath.py
import posixpath # precompiled from /usr/lib/python2.4/posixpath.pyc
# /usr/lib/python2.4/stat.pyc matches /usr/lib/python2.4/stat.py
import stat # precompiled from /usr/lib/python2.4/stat.pyc
import errno # builtin
# /usr/lib/python2.4/UserDict.pyc matches /usr/lib/python2.4/UserDict.py
import UserDict # precompiled from /usr/lib/python2.4/UserDict.pyc
# /usr/lib/python2.4/copy_reg.pyc matches /usr/lib/python2.4/copy_reg.py
import copy_reg # precompiled from /usr/lib/python2.4/copy_reg.pyc
# /usr/lib/python2.4/types.pyc matches /usr/lib/python2.4/types.py
import types # precompiled from /usr/lib/python2.4/types.pyc
import japanese # directory /usr/lib/python2.4/site-packages/japanese
# /usr/lib/python2.4/site-packages/japanese/__init__.pyc matches /usr/lib/python2.4/site-packages/japanese/__init__.py
import japanese # precompiled from /usr/lib/python2.4/site-packages/japanese/__init__.pyc
import japanese.aliases # directory /usr/lib/python2.4/site-packages/japanese/aliases
# /usr/lib/python2.4/site-packages/japanese/aliases/__init__.pyc matches /usr/lib/python2.4/site-packages/japanese/aliases/__init__.py
import japanese.aliases # precompiled from /usr/lib/python2.4/site-packages/japanese/aliases/__init__.pyc
import encodings # directory /usr/lib/python2.4/encodings
# /usr/lib/python2.4/encodings/__init__.pyc matches /usr/lib/python2.4/encodings/__init__.py
import encodings # precompiled from /usr/lib/python2.4/encodings/__init__.pyc
# /usr/lib/python2.4/codecs.pyc matches /usr/lib/python2.4/codecs.py
import codecs # precompiled from /usr/lib/python2.4/codecs.pyc
import _codecs # builtin
# /usr/lib/python2.4/encodings/aliases.pyc matches /usr/lib/python2.4/encodings/aliases.py
import encodings.aliases # precompiled from /usr/lib/python2.4/encodings/aliases.pyc
# /usr/lib/python2.4/warnings.pyc matches /usr/lib/python2.4/warnings.py
import warnings # precompiled from /usr/lib/python2.4/warnings.pyc
# /usr/lib/python2.4/linecache.pyc matches /usr/lib/python2.4/linecache.py
import linecache # precompiled from /usr/lib/python2.4/linecache.pyc
# /usr/lib/python2.4/encodings/utf_8.pyc matches /usr/lib/python2.4/encodings/utf_8.py
import encodings.utf_8 # precompiled from /usr/lib/python2.4/encodings/utf_8.pyc
Python 2.4.3 (#1, Sep  3 2009, 15:37:12)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-46)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
dlopen("/usr/lib/python2.4/lib-dynload/readline.so", 2);
import readline # dynamically loaded from /usr/lib/python2.4/lib-dynload/readline.so
>>>


# python
Python 2.4.3 (#1, Sep  3 2009, 15:37:12)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-46)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>

现在,终于找回久违的python2.4.3了,再执行yum安装一个包试试。
# yum install rrdtool
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* addons: centos.tt.co.kr
* base: ftp.cse.yzu.edu.tw
* extras: centos.tt.co.kr
* updates: data.nicehosting.co.kr
addons                                                                                                       |  951 B     00:00

一切ok了。

论坛徽章:
0
6 [报告]
发表于 2010-11-12 11:36 |只看该作者
确实不应该删除系统自带的版本,有可能系统本身某些地方对该版本还有依赖。
建议保留系统自带的版本,在其它目录另外安装一个。

论坛徽章:
0
7 [报告]
发表于 2011-11-16 16:19 |只看该作者
mark备用

论坛徽章:
0
8 [报告]
发表于 2017-04-24 11:33 |只看该作者
本帖最后由 matata 于 2017-04-24 11:52 编辑

mark一下,CentOS 6.7里自带的2.6.6,自己又编译安装了Python 2.7.13,现在又打算退回去。

重新link回去了,自带的在/usr/bin/python下面。

# python
Python 2.6.6 (r266:84292, Aug 18 2016, 15:13:37)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-17)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>

论坛徽章:
0
9 [报告]
发表于 2017-04-24 11:55 |只看该作者
You are using pip version 8.1.2, however version 9.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP