3

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'
user1245262
  • 6,968
  • 8
  • 50
  • 77
  • What about `import numpy as np, dask, skimage` (each on a separate statement)? – CristiFati Jun 21 '19 at 20:16
  • There must be some conditional imports in the mix here. On the first try, skimage imports skimage.util, this in turn dask.array, which tries to load its routines. On the second import, this chain is broken because one of the packages is already loaded, though some of its (optional) dependencies are not. – Roland Weber Jun 21 '19 at 20:51
  • @CristiFati - Nope, didn't work, but thx for the suggestion – user1245262 Jun 24 '19 at 14:51
  • Anyway, I see you found your answer! – CristiFati Jun 24 '19 at 15:28

1 Answers1

1

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
user7138814
  • 1,991
  • 9
  • 11
  • Thanks, I was aware of the version issue and had been using anaconda-navigator to try to select two compatible versions. But, what puzzled me was why the first import failed and the second succeeded. I would've thought either both should fail or both succeed. – user1245262 Jun 24 '19 at 14:30