chembl / chembl_webresource_client

Official Python client for accessing ChEMBL API
https://www.ebi.ac.uk/chembl/api/data/docs
Other
359 stars 95 forks source link

ImportError: cannot import name 'hashlib' from 'requests_cache.backends.base' #96

Closed gedeck closed 3 years ago

gedeck commented 3 years ago

In the latest release of requests-cache (0.6.0), hashlib is no longer imported in requests_cache/backends/base.py leading to this import error:

  File "..../chembl_webresource_client/cache.py", line 3, in <module>
    from requests_cache.backends.base import BaseCache, hashlib, _to_bytes
ImportError: cannot import name 'hashlib' from 'requests_cache.backends.base' (.../requests_cache/backends/base.py)

The relevant line is this:

from requests_cache.backends.base import BaseCache, hashlib, _to_bytes

This should be fixable by importing hashlib directly

import hashlib

_to_bytes is also no longer available in requests-cache. The previous implementation was:

def _to_bytes(s, encoding='utf-8'):
    return s if isinstance(s, bytes) else bytes(s, encoding)
eloyfelix commented 3 years ago

many thanks for reporting the issue and the solution! We'll release a new version with the fixes during the week.

eloyfelix commented 3 years ago

fixed and version 0.10.3 now avaiable in pypi: https://pypi.org/project/chembl-webresource-client/