Skip to content

Pooch update breaks import #5528

@manthey

Description

@manthey

Description

Pooch recently updated to version 1.5.0. This moved the hash functions to their own module, so the current method of importing them now fails. Further, the fallback for if pooch is not installed doesn't work because the exact error is different.

Way to reproduce

import skimage.metrics

Note, install pooch 1.5.0 first.

You'll see

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File ".../python3.8/site-packages/skimage/__init__.py", line 135, in <module>
    from .data import data_dir
  File ".../python3.8/site-packages/skimage/data/__init__.py", line 64, in <module>
    from pooch.utils import file_hash
ImportError: cannot import name 'file_hash' from 'pooch.utils' (.../python3.8/site-packages/pooch/utils.py)

Version information

# Paste the output of the following python commands
from __future__ import print_function
import sys; print(sys.version)
import platform; print(platform.platform())
import skimage; print("scikit-image version: {}".format(skimage.__version__))
import numpy; print("numpy version: {}".format(numpy.__version__))
# your output here
3.8.10 (default, May  5 2021, 03:01:07)
[GCC 7.5.0]
Linux-5.4.0-80-generic-x86_64-with-glibc2.27
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File ".../python3.8/site-packages/skimage/__init__.py", line 135, in <module>
    from .data import data_dir
  File ".../python3.8/site-packages/skimage/data/__init__.py", line 64, in <module>
    from pooch.utils import file_hash
ImportError: cannot import name 'file_hash' from 'pooch.utils' (.../python3.8/site-packages/pooch/utils.py)
numpy version: 1.21.2

I'm using scikit-image version: 0.18.2

Possible Fix

One solution would be to change skimage/data/__init__.py, where it reads

    from pooch.utils import file_hash

to

    try:
        from pooch.utils import file_hash
    except ImportError:
        from pooch.hashes import file_hash

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions