Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Import error (numpy.ufunc) with python 2.7 and numpy 1.16.2 #3818

Closed
edrozenberg opened this issue Mar 28, 2019 · 10 comments
Closed

Import error (numpy.ufunc) with python 2.7 and numpy 1.16.2 #3818

edrozenberg opened this issue Mar 28, 2019 · 10 comments

Comments

@edrozenberg
Copy link

edrozenberg commented Mar 28, 2019

Description

Trying to import skimage causes AttributeError: 'numpy.ufunc' object has no attribute '__module__' when using python 2.7, skimage 0.14.2, numpy 1.16.2 .

Way to reproduce

import skimage

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__))
2.7.16 (default, Mar  3 2019, 19:53:40) 
[GCC 8.3.0]
Linux-4.19.30-x86_64-Intel-R-_Xeon-R-_CPU_E5-2630_v3_@_2.40GHz-with-slackware-14.2

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib64/python2.7/site-packages/skimage/__init__.py", line 167, in <module>
    from .util.dtype import (img_as_float32,
  File "/usr/lib64/python2.7/site-packages/skimage/util/__init__.py", line 6, in <module>
    from .apply_parallel import apply_parallel
  File "/usr/lib64/python2.7/site-packages/skimage/util/apply_parallel.py", line 8, in <module>
    import dask.array as da
  File "/usr/lib64/python2.7/site-packages/dask/array/__init__.py", line 9, in <module>
    from .routines import (take, choose, argwhere, where, coarsen, insert,
  File "/usr/lib64/python2.7/site-packages/dask/array/routines.py", line 256, in <module>
    @wraps(np.matmul)
  File "/usr/lib64/python2.7/functools.py", line 33, in update_wrapper
    setattr(wrapper, attr, getattr(wrapped, attr))
AttributeError: 'numpy.ufunc' object has no attribute '__module__'

numpy version: 1.16.2
  • Problem only happens with python 2.7. Works fine under python 3.7. Same versions of everything.
  • numpy was compiled from source for both python2 and python3
  • scikit-image - same issue whether I use precompiled from pip2 or compile from source
  • I double-checked that I don't have multiple versions of anything
  • The only thing that fixes things under python2 so far is pip2 install scikit-image==0.12.2
# pip2 list|grep numpy
numpy 1.16.2          

# pip3 list|grep numpy
numpy                1.16.2   
@stefanv
Copy link
Member

stefanv commented Mar 28, 2019 via email

@edrozenberg
Copy link
Author

edrozenberg commented Mar 28, 2019

Thanks but 0.14.2 is what causes the problem. I was just showing that 0.12.2 is what works, and that is what I have installed now after 0.14.2 failed to work. I'll edit my post to remove that confusing info.

@edrozenberg
Copy link
Author

I'll have to try 0.15dev and see if that makes any difference.

@stefanv
Copy link
Member

stefanv commented Mar 28, 2019

Sorry, I didn't check properly: the error you are seeing is coming from dask.

@stefanv
Copy link
Member

stefanv commented Mar 28, 2019

(I.e., you should first try to upgrade dask.)

@edrozenberg
Copy link
Author

Brilliant! Was not aware dask was involved. Fixed by updating dask:

# pip2 install -U dask

Installing collected packages: dask
  Found existing installation: dask 1.0.0
    Uninstalling dask-1.0.0:
      Successfully uninstalled dask-1.0.0
Successfully installed dask-1.1.4

@ranka47
Copy link

ranka47 commented Jul 29, 2019

sudo pip install -U dask numpy scikit-image
Requirement already up-to-date: dask in /usr/local/lib/python2.7/dist-packages (1.2.2)
Requirement already up-to-date: numpy in /usr/local/lib/python2.7/dist-packages (1.16.4)
Requirement already up-to-date: scikit-image in /usr/local/lib/python2.7/dist-packages (0.14.3)
Requirement already satisfied, skipping upgrade: cloudpickle>=0.2.1 in /usr/local/lib/python2.7/dist-packages (from scikit-image) (1.2.1)
Requirement already satisfied, skipping upgrade: pillow>=4.3.0 in /usr/local/lib/python2.7/dist-packages (from scikit-image) (6.1.0)
Requirement already satisfied, skipping upgrade: scipy>=0.17.0 in /usr/lib/python2.7/dist-packages (from scikit-image) (0.17.0)
Requirement already satisfied, skipping upgrade: six>=1.10.0 in /usr/lib/python2.7/dist-packages (from scikit-image) (1.10.0)
Requirement already satisfied, skipping upgrade: PyWavelets>=0.4.0 in /usr/local/lib/python2.7/dist-packages (from scikit-image) (1.0.3)
Requirement already satisfied, skipping upgrade: networkx>=1.8 in /usr/local/lib/python2.7/dist-packages (from scikit-image) (2.2)
Requirement already satisfied, skipping upgrade: matplotlib>=2.0.0 in /usr/local/lib/python2.7/dist-packages (from scikit-image) (2.2.4)
Requirement already satisfied, skipping upgrade: decorator>=4.3.0 in /usr/local/lib/python2.7/dist-packages (from networkx>=1.8->scikit-image) (4.4.0)
Requirement already satisfied, skipping upgrade: pyparsing!=2.0.4,!=2.1.2,!=2.1.6,>=2.0.1 in /usr/lib/python2.7/dist-packages (from matplotlib>=2.0.0->scikit-image) (2.0.3)
Requirement already satisfied, skipping upgrade: backports.functools-lru-cache in /usr/local/lib/python2.7/dist-packages (from matplotlib>=2.0.0->scikit-image) (1.5)
Requirement already satisfied, skipping upgrade: subprocess32 in /usr/local/lib/python2.7/dist-packages (from matplotlib>=2.0.0->scikit-image) (3.5.4)
Requirement already satisfied, skipping upgrade: pytz in /usr/lib/python2.7/dist-packages (from matplotlib>=2.0.0->scikit-image) (2014.10)
Requirement already satisfied, skipping upgrade: python-dateutil>=2.1 in /usr/lib/python2.7/dist-packages (from matplotlib>=2.0.0->scikit-image) (2.4.2)
Requirement already satisfied, skipping upgrade: kiwisolver>=1.0.1 in /usr/local/lib/python2.7/dist-packages (from matplotlib>=2.0.0->scikit-image) (1.1.0)
Requirement already satisfied, skipping upgrade: cycler>=0.10 in /usr/local/lib/python2.7/dist-packages (from matplotlib>=2.0.0->scikit-image) (0.10.0)
Requirement already satisfied, skipping upgrade: setuptools in /usr/lib/python2.7/dist-packages (from kiwisolver>=1.0.1->matplotlib>=2.0.0->scikit-image) (20.7.0)

Python version: 2.7.15
numpy Version: 1.16.4
dask Version: 1.2.2
scikit-image Version: 0.14.3

I am getting the same error.

Is there any other solution to this? I upgraded all three packages.
It worked before with
numpy version: 1.12.0
scikit-image: 0.14.1
dask: 1.0.0
However, when I upgraded numpy for pyarrow, it broke.

@hmaarrfk
Copy link
Member

please do not use sudo and pip at the same time. You very likely broke your system python installation :( That said, I don't think many system utilities use numpy, so you are likely safe.
https://dev.to/elabftw/stop-using-sudo-pip-install-52mn

The installation instructions should be updated with a caution about this
https://scikit-image.org/docs/stable/install.html

The contribution guide goes over how to create virtual environments
https://scikit-image.org/docs/stable/contribute.html#build-environment-setup
Instead of the

pip install -e .

command, use

pip install scikit-image
# or
conda install scikit-image

to install scikit-image in the virtual environment.

@hmaarrfk
Copy link
Member

I would try to see if you can install things in a virtual environment, if not, please open a new issue.

I would strongly suggest to use conda for scientific stuff.

@ranka47
Copy link

ranka47 commented Aug 15, 2019

Thanks for the advice.
By removing the dask dependency, it is working.
numpy (1.16.4)
scikit-image (0.14.3)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants