keybase / python-triplesec

A Python port of the triplesec library.
BSD 3-Clause "New" or "Revised" License
82 stars 18 forks source link

TripleSec throws errors loading sha3 in python 2.6.6 on CentOS 6.4 #8

Closed mbainter closed 5 years ago

mbainter commented 9 years ago

With the default python package on CentOS 6, and python-pip and python-devel installed, I did the pip install TripleSec, which installed: TripleSec pycrypto scrypt six pysha3 twofish salsa20

When I try to run triplesec I get this output:

$ triplesec
Traceback (most recent call last):
  File "/usr/bin/triplesec", line 9, in <module>
    load_entry_point('TripleSec==0.3', 'console_scripts', 'triplesec')()
  File "/usr/lib/python2.6/site-packages/pkg_resources.py", line 299, in load_entry_point
    return get_distribution(dist).load_entry_point(group, name)
  File "/usr/lib/python2.6/site-packages/pkg_resources.py", line 2229, in load_entry_point
    return ep.load()
  File "/usr/lib/python2.6/site-packages/pkg_resources.py", line 1948, in load
    entry = __import__(self.module_name, globals(),globals(), ['__name__'])
  File "/usr/lib/python2.6/site-packages/triplesec/__init__.py", line 21, in <module>
    from .utils import (
  File "/usr/lib/python2.6/site-packages/triplesec/utils.py", line 18, in <module>
    import sha3
  File "/usr/lib64/python2.6/site-packages/sha3.py", line 11, in <module>
    _hashlib_constructor = _hashlib.__get_builtin_constructor
AttributeError: 'module' object has no attribute '__get_builtin_constructor'

Since it looks like it is actually a problem with pysha3 I tried loading it directly:

>>> import sys
>>> import hashlib
>>> sys.version_info
(2, 6, 6, 'final', 0)
>>> import sha3
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib64/python2.6/site-packages/sha3.py", line 11, in <module>
    _hashlib_constructor = _hashlib.__get_builtin_constructor
AttributeError: 'module' object has no attribute '__get_builtin_constructor'

I tried searching for any indication someone else had run into this error, and poked around with the pysha3 implementation -- but they don't actually have a bug-tracker. Is there a known workaround for this issue?

santhoshdivakar commented 9 years ago

Hi, I hope you have solved the problem already. I faced the same issue and I did a little hack into the system. I had python-2.7.9 with me. So in the "site-packages/sha3.py" file I replaced the line:11 with _hashlib_constructor = _hashlib.builtins

I also noticed that when doing this, this is the only way to call the sha3 function : s = hashlib.sha3_512()

-Hope this helps Santhosh Divakar