문제

I've tried a couple of searches and I don't think this has been asked, but if this is a duplicate please forgive me. I'm trying to use urllib on python-2.7 to read from a web page. Very simple application, all I want to do is get some text from a page. Unfortunately the following code:

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

returns an error talking about the "hash code" not being found:

 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

I've tried a lot of Google searching but nothing that's turned up so far has been very useful. Any ideas?

도움이 되었습니까?

해결책

The following page explains the package you need to install:

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

In summary: You need to install hashlib library using the following commands:

tar xvfz hashlib-20081119.tar.gz
cd hashlib-20081119
sudo python setup.py install
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top