python错误"AttributeError:'模块'对象没有属性'sha1'" [英] python error "AttributeError: 'module' object has no attribute 'sha1'"

查看:646
本文介绍了python错误"AttributeError:'模块'对象没有属性'sha1'"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要您的帮助

如何更正错误AttributeError:模块"对象没有属性"sha1",

How to correct an error AttributeError: 'module' object has no attribute 'sha1',

当我启动命令示例import random或import hashlib时,我得到这样的结果

When I start the command example import random or import hashlib I get such a result

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'
>>> 

推荐答案

似乎您有一个名为hashlib.py的文件,该文件妨碍了解释器查找标准的hashlib模块.

It looks like you have a file called hashlib.py that gets in the way of the interpreter finding the standard hashlib module.

这篇关于python错误"AttributeError:'模块'对象没有属性'sha1'"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆