0

I have a problem that is very similar to this one:

Error importing hashlib with python 2.7 but not with 2.6

However, I need a different solution because this is on an embedded system and I can't just use pip or apt-get to install everything. What I need to know is: what specific files are missing and how can I get hashlib to import correctly?

To clarify, my errors are the same as in the original post. The core issue appears to be that the built-in _hashlib module seems to be missing, but there's no _hashlib.so I'm not sure where to even find it.

Errors from Referenced Post:

root@myserver [PROD] # python2.7 -c "import hashlib"
ERROR:root:code for hash md5 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 ' + name)
ValueError: unsupported hash type md5
ERROR:root:code for hash sha1 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 ' + name)
ValueError: unsupported hash type sha1
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 ' + 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 ' + 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 ' + 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 ' + name)
ValueError: unsupported hash type sha512
Jake
  • 7,565
  • 6
  • 55
  • 68
  • Have you tried to import hashlib from your embedded system? What specific errors is it giving you? – metatoaster Mar 10 '14 at 06:42
  • @metatoaster the exact same errors as were found in the original post. – Jake Mar 10 '14 at 07:13
  • It'd be better that in addition to referencing the question, you [edit] your post to include the error messages so this question has enough information to stand on its own. (That post could disappear, or people might not want to flip between questions to find out what you're referring to) – Jon Clements Mar 10 '14 at 07:22
  • How did you install python2.7 onto your embedded system? Did you compile it from source? Have you got `libssl1` installed? – metatoaster Mar 10 '14 at 09:45

1 Answers1

1

Here is a link to a python implementation of sha (224, 256, 512, 384).

Jake
  • 7,565
  • 6
  • 55
  • 68