【发布时间】:2014-04-03 16:46:00
【问题描述】:
我需要你的帮助,
如何纠正错误 AttributeError: 'module' object has no attribute 'sha1',
当我启动命令示例 import random 或 import hashlib 我得到这样的结果
root@thinkad:~# python
Python 2.7.3 (default, Jan 2 2013, 13:56:14)
[GCC 4.7.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import random
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.7/random.py", line 49, in <module>
import hashlib as _hashlib
File "hashlib.py", line 3, in <module>
hasher = hashlib.sha1()
AttributeError: 'module' object has no attribute 'sha1'
>>> import math
>>> import hashlib
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "hashlib.py", line 3, in <module>
hasher = hashlib.sha1()
AttributeError: 'module' object has no attribute 'sha1'
>>>
【问题讨论】:
-
您能否运行
import hashlib; print dir(hashlib), hashlib.__file__并将输出包含在问题中。 -
相同的 AttributeError: 'module' 对象没有属性 'sha1'
标签: linux python-2.7 hashlib