3

我已经尝试了几次搜索,但我认为没有人问过这个问题,但如果这是重复的,请原谅我。我正在尝试在 python-2.7 上使用 urllib 来读取网页。非常简单的应用程序,我要做的就是从页面中获取一些文本。不幸的是以下代码:

import urllib
address = "http://google.co.uk"
page = urllib.urlopen(address)

返回一个关于未找到“哈希码”的错误:

 ERROR:root:code for hash sha224 was not found.
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/hashlib.py", line 139, in <module>
    globals()[__func_name] = __get_hash(__func_name)
  File "/usr/local/lib/python2.7/hashlib.py", line 91, in __get_builtin_constructor
    raise ValueError('unsupported hash type %s' % name)
ValueError: unsupported hash type sha224
ERROR:root:code for hash sha256 was not found.
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/hashlib.py", line 139, in <module>
    globals()[__func_name] = __get_hash(__func_name)
  File "/usr/local/lib/python2.7/hashlib.py", line 91, in __get_builtin_constructor
    raise ValueError('unsupported hash type %s' % name)
ValueError: unsupported hash type sha256
ERROR:root:code for hash sha384 was not found.
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/hashlib.py", line 139, in <module>
    globals()[__func_name] = __get_hash(__func_name)
  File "/usr/local/lib/python2.7/hashlib.py", line 91, in __get_builtin_constructor
    raise ValueError('unsupported hash type %s' % name)
ValueError: unsupported hash type sha384
ERROR:root:code for hash sha512 was not found.
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/hashlib.py", line 139, in <module>
    globals()[__func_name] = __get_hash(__func_name)
  File "/usr/local/lib/python2.7/hashlib.py", line 91, in __get_builtin_constructor
    raise ValueError('unsupported hash type %s' % name)
ValueError: unsupported hash type sha512

我已经尝试了很多谷歌搜索,但到目前为止没有任何发现非常有用。有任何想法吗?

4

1 回答 1

2

以下页面解释了您需要安装的软件包:

http://new2python.blogspot.com/2012/07/errorrootcode-for-hash-sha224-was-not.html

总之:您需要使用以下命令安装 hashlib 库:

tar xvfz hashlib-20081119.tar.gz
cd hashlib-20081119
sudo python setup.py install
于 2012-11-15T15:53:42.290 回答