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

cannot import name '_validate_lengths' #12744

Closed
rodrigo2019 opened this issue Jan 15, 2019 · 21 comments
Closed

cannot import name '_validate_lengths' #12744

rodrigo2019 opened this issue Jan 15, 2019 · 21 comments

Comments

@rodrigo2019
Copy link

it occurs only with numpy 1.16, numpy 1.15 works fine

Using TensorFlow backend.
Traceback (most recent call last):
  File ".\predict.py", line 4, in <module>
    from frontend import YOLO
  File "C:\RepositoriosGit\keras-yolo2\frontend.py", line 8, in <module>
    from preprocessing import BatchGenerator
  File "C:\RepositoriosGit\keras-yolo2\preprocessing.py", line 1, in <module>
    from imgaug import augmenters as iaa
  File "C:\Program Files\Python36\lib\site-packages\imgaug\__init__.py", line 2, in <module>
    from imgaug.imgaug import *
  File "C:\Program Files\Python36\lib\site-packages\imgaug\imgaug.py", line 22, in <module>
    import skimage.draw
  File "C:\Program Files\Python36\lib\site-packages\skimage\__init__.py", line 167, in <module>
    from .util.dtype import (img_as_float32,
  File "C:\Program Files\Python36\lib\site-packages\skimage\util\__init__.py", line 8, in <module>
    from .arraycrop import crop
  File "C:\Program Files\Python36\lib\site-packages\skimage\util\arraycrop.py", line 8, in <module>
    from numpy.lib.arraypad import _validate_lengths
ImportError: cannot import name '_validate_lengths'

Numpy/Python version information:

>>> import sys, numpy; print(numpy.__version__, sys.version)
1.16.0 3.6.8 (tags/v3.6.8:3c6b436a57, Dec 24 2018, 00:16:47) [MSC v.1916 64 bit (AMD64)]
@matthew-brett
Copy link
Contributor

Yes, it looks like this disappeared in numpy 1.16.0. But, as you probably noticed, the function has a prepended underscore, meaning that scikit-image was being a bit naughty importing that function.

There's a scikit-image issue here: scikit-image/scikit-image#3649

Closing in favor of that issue.

@rodrigo2019
Copy link
Author

Thank you @matthew-brett for your quick answer.

@stefanv
Copy link
Contributor

stefanv commented Jan 17, 2019

Yes, it looks like this disappeared in numpy 1.16.0. But, as you probably noticed, the function has a prepended underscore, meaning that scikit-image was being a bit naughty importing that function.

Correct. To give some context, this function came from scikit-image originally, and was ported to NumPy, and we didn't clean up very well afterwards. I think the pain associated with fixing this will be a vivid reminder not to do this again in the future.

@stefanv
Copy link
Contributor

stefanv commented Jan 18, 2019

v0.14.2 has been released and addresses the issue.

@koliza
Copy link

koliza commented Mar 8, 2019

Hi, have the same problem. Just update all packages.

Successfully installed PyWavelets-1.0.2 backports.functools-lru-cache-1.5 cloudpickle-0.8.0 cycler-0.10.0 dask-1.1.3 decorator-4.3.2 kiwisolver-1.0.1 matplotlib-2.2.4 networkx-2.2 numpy-1.16.2 pillow-5.4.1 pyparsing-2.3.1 python-dateutil-2.8.0 pytz-2018.9 scikit-image-0.14.2 scipy-1.2.1 setuptools-40.8.0 six-1.12.0 subprocess32-3.5.3 toolz-0.9.0

Can anybody help me to solve this problem?

@stefanv
Copy link
Contributor

stefanv commented Mar 9, 2019

Please report the output of the following:

import skimage
print(skimage.__version__)

@koliza
Copy link

koliza commented Mar 9, 2019

I have this

ImportError: cannot import name '_validate_lengths' from 'numpy.lib.arraypad' (/home/liza/anaconda3/lib/python3.7/site-packages/numpy/lib/arraypad.py)

@mattip
Copy link
Member

mattip commented Mar 9, 2019

@stefanv would it make sense if he has scikit-image-0.14.2 (in the comment just before yours)?

@stefanv
Copy link
Contributor

stefanv commented Mar 9, 2019

Sorry, my brain was clearly on holiday.

0.14.2 fixed this problem, so I imagine another version of the library is being imported. But I don't know how to show that, given that the previous comment states the opposite.

@koliza
Copy link

koliza commented Mar 9, 2019

I have already solved this problem, just use conda install -c conda-forge scikit-image, not pip install -U scikit-image

@pol690
Copy link

pol690 commented Mar 14, 2019

I have already solved this problem, just use conda install -c conda-forge scikit-image, not pip install -U scikit-image

That solved it for me

@pandagre
Copy link

ImportError: cannot import name '_validate_lengths' from 'numpy.lib.arraypad' (C:\Users\basant\Anaconda3\lib\site-packages\numpy\lib\arraypad.py)

@pandagre
Copy link

i have this problem anyone please give the solution for this

@stefanv
Copy link
Contributor

stefanv commented Apr 29, 2019

@pandagre Please ensure that you have the latest version of scikit-image installed. If you still experience problems, open a new issue and we'll try to help.

@superkoma
Copy link

I have already solved this problem, just use conda install -c conda-forge scikit-image, not pip install -U scikit-image

This works for me, thanks.

@yexing99
Copy link

I used conda install -c conda-forge scikit-image but the version I got is 0.14.0. I still have the issue of cannot import name '_validate_lengths'

@stefanv
Copy link
Contributor

stefanv commented May 14, 2019

@yexing99 Please try and install the latest version of scikit-image and numpy. That combination is known to work. Otherwise, please open a new issue and help us debug your setup there, providing all version numbers.

@yakovkeselman
Copy link

# The following worked fine for me
pip install -U scikit-image

Installing collected packages: scikit-image
Found existing installation: scikit-image 0.14.1
Uninstalling scikit-image-0.14.1:
Successfully uninstalled scikit-image-0.14.1
Successfully installed scikit-image-0.15.0

python -c "import skimage"
# No errors, as expected

@HudsonHuang
Copy link

HudsonHuang commented Jun 19, 2019

I have already solved this problem, just use conda install -c conda-forge scikit-image, not pip install -U scikit-image

As conda install is so slow for me, I tried pip install -U scikit-image and it's also work.

@07Agarg
Copy link

07Agarg commented Jun 20, 2019

pip install -U scikit-image
This worked for me.

@kidwithakeybord
Copy link

Ya same,
pip install -U scikit-image
This worked for me.

@numpy numpy locked as resolved and limited conversation to collaborators Jun 25, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests