1

I installed a python package that I need, and tried to import it, but there's a line of code in the package:

from hashlib import blake2s

which returned the error:

ImportError: cannot import name 'blake2s'

After a bit of reading, I found that the hashlib module in Python 3.6+ has blake2s, but I'm using Python 3.5.6. Updating my Python version would solve this problem, but I don't have admin access on this system. So I'm stuck on Python 3.5.6.

Is there a way to get blake2s working in Python 3.5?

edit: I'm wondering if this can be used somehow... https://github.com/dchest/pyblake2

winampman
  • 484
  • 5
  • 15
  • 3
    you should be able to install python for yourself (not systemwide) without privilege elevation. – M Z Jan 12 '21 at 04:19
  • Thanks for the suggestion, but I also need to use Python notebooks that are configured (by admins) to use the Python version installed on the server. – winampman Jan 12 '21 at 05:15
  • Depending on your situation, you can replace member function or subclass the relevant library based on thr new code. See this https://stackoverflow.com/questions/50599045/python-replacing-a-function-within-a-class-of-a-module – yoonghm Jan 12 '21 at 06:53

1 Answers1

2

Answering my own question... I installed the pyblake2 package (linked in my edit above), then went inside the package I was trying to install and modified the import line.

I changed from hashlib import blake2s to from pyblake2 import blake2s and then reinstalled the package with that modified line.

It worked! The package is working in Python 3.5 even though Python 3.5 hashlib does not have blake2s.

winampman
  • 484
  • 5
  • 15