当我尝试在gnome上使用终端打开Gajim时,我得到以下信息:
Traceback (most recent call last):
File "gajim.py", line 106, in <module>
import common.configpaths
File "/usr/share/gajim/src/common/configpaths.py", line 27, in <module>
import tempfile
File "/usr/lib64/python2.6/tempfile.py", line 34, in <module>
from random import Random as _Random
File "/usr/lib64/python2.6/random.py", line 47, in <module>
from os import urandom as _urandom
ImportError: cannot import name urandom知道怎么解决这个问题吗?
我的操作系统是Mandriva 2010.1,Python从v2.4升级到v2.6
发布于 2013-04-19 16:05:50
您可能导入了错误的os.py模块。尝试启动python2.6,然后
>>> import os
>>> print os.__file__那应该是/usr/lib64/python2.6/os.py或/usr/lib64/python2.6/os.pyc。如果没有删除(或重命名)您找到的文件。如果是这样的话:
>>> os.urandom(3)这应该会给你一个3个字符的字符串。如果是这样的话,那么gajim找错了os.py模块。如果您获得了与运行gajim时相同的错误,那么如果/usr/lib64/python2.6/os.py不存在(使用行if not _exists("urandom":),则应该在它的末尾定义urandom。
如果没有定义它,就像python-2.6.5-2.5mdv2010.2.x86_64的情况一样,并且存在/dev/urandom,您可以尝试重新添加代码:
if not _exists("urandom"):
def urandom(n):
"""urandom(n) -> str
Return a string of n random bytes suitable for cryptographic use.
"""
try:
_urandomfd = open("/dev/urandom", O_RDONLY)
except (OSError, IOError):
raise NotImplementedError("/dev/urandom (or equivalent) not found")
try:
bs = b""
while n - len(bs) >= 1:
bs += read(_urandomfd, n - len(bs))
finally:
close(_urandomfd)
return bs另请参阅:这错误报告
https://unix.stackexchange.com/questions/73018
复制相似问题