Search code examples
pythonpython-2.7numpydaskscikit-image

Why does first import of skimage fail, but second one succeed?


When I import skimage, I get an odd error message that seems to be connected to version mismatch issues with scikit-image, numpy and dask, but if I immediately try to import again, everything is fine -- i.e.

(base) me@balin:~$ python
Python 2.7.15 |Anaconda, Inc.| (default, Dec 14 2018, 19:04:19) 
[GCC 7.3.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import skimage
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/me/anaconda2/lib/python2.7/site-packages/skimage/__init__.py", line 167, in <module>
    from .util.dtype import (img_as_float32,
  File "/home/me/anaconda2/lib/python2.7/site-packages/skimage/util/__init__.py", line 6, in <module>
    from .apply_parallel import apply_parallel
  File "/home/me/anaconda2/lib/python2.7/site-packages/skimage/util/apply_parallel.py", line 8, in <module>
    import dask.array as da
  File "/home/me/anaconda2/lib/python2.7/site-packages/dask/array/__init__.py", line 9, in <module>
    from .routines import (take, choose, argwhere, where, coarsen, insert,
  File "/home/me/anaconda2/lib/python2.7/site-packages/dask/array/routines.py", line 256, in <module>
    @wraps(np.matmul)
  File "/home/me/anaconda2/lib/python2.7/functools.py", line 33, in update_wrapper
    setattr(wrapper, attr, getattr(wrapped, attr))
AttributeError: 'numpy.ufunc' object has no attribute '__module__'
>>> import skimage
>>> 

>>> skimage.__version__
'0.14.2'

>>> import numpy as np
>>> np.__version__
'1.16.2'

>>> import dask
>>> dask.__version__
u'1.0.0'

Solution

  • These versions of dask and numpy are incompatible, apparently. There are multiple bug reports about this

    https://github.com/scikit-image/scikit-image/issues/3649
    https://github.com/scikit-image/scikit-image/issues/3654
    https://github.com/scikit-image/scikit-image/issues/3818

    The solution seems to be updating dask, so maybe try

    conda update --no-update-deps dask