Kaggle/docker-python

ImportError: cannot import name 'QhullError' from 'scipy.spatial'

anwai98 opened this issue ยท 3 comments

๐Ÿ› Bug

To Reproduce

Running the snippet below on "GPU P100" (as it is):

from skimage.segmentation import find_boundaries, watershed

Expected behavior

The modules are called as expected while the "Accelerator" is set to "None", but it throws an error on the GPUs.

Additional context

Raised error:

/opt/conda/lib/python3.10/site-packages/scipy/__init__.py:146: UserWarning: A NumPy version >=1.16.5 and <1.23.0 is required for this version of SciPy (detected version 1.24.3
  warnings.warn(f"A NumPy version >={np_minversion} and <{np_maxversion}"
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
Cell In[1], line 1
----> 1 from skimage.segmentation import find_boundaries, watershed

File /opt/conda/lib/python3.10/site-packages/skimage/segmentation/__init__.py:7
      5 from .slic_superpixels import slic
      6 from ._quickshift import quickshift
----> 7 from .boundaries import find_boundaries, mark_boundaries
      8 from ._clear_border import clear_border
      9 from ._join import join_segmentations, relabel_sequential

File /opt/conda/lib/python3.10/site-packages/skimage/segmentation/boundaries.py:5
      2 from scipy import ndimage as ndi
      4 from .._shared.utils import _supported_float_type
----> 5 from ..morphology import dilation, erosion, square
      6 from ..util import img_as_float, view_as_windows
      7 from ..color import gray2rgb

File /opt/conda/lib/python3.10/site-packages/skimage/morphology/__init__.py:12
     10 from ..measure._label import label
     11 from ._skeletonize import medial_axis, skeletonize, skeletonize_3d, thin
---> 12 from .convex_hull import convex_hull_image, convex_hull_object
     13 from .grayreconstruct import reconstruction
     14 from .misc import remove_small_holes, remove_small_objects

File /opt/conda/lib/python3.10/site-packages/skimage/morphology/convex_hull.py:4
      2 from itertools import product
      3 import numpy as np
----> 4 from scipy.spatial import ConvexHull, QhullError
      5 from ..measure.pnpoly import grid_points_in_poly
      6 from ._convex_hull import possible_hull

ImportError: cannot import name 'QhullError' from 'scipy.spatial' (/opt/conda/lib/python3.10/site-packages/scipy/spatial/__init__.py)

@anwai98 Try this temporary solution:

from scipy.spatial.qhull import QhullError
from scipy import spatial
spatial.QhullError = QhullError 

It worked for me in Kaggle notebook.

Hi @guitarmind, thanks for the solution.

I think this issue is fixed. I tried running my desired command just now without any workarounds (from skimage.segmentation import find_boundaries, watershed), and looks like it's fixed somehow (the QHullError import error doesn't pop anymore).

We are actively closing out old bugs,

On a new notebook, this import works.
This may have been self resolved, can't finding anything on our end to link to fix.

Screenshot 2024-06-04 at 12 41 16โ€ฏPM

closing out for being outdated and fixed