", line 1, in File "/opt/AI/AN/lib/python3.7/site-packages/skimage/__init__..._skimage numpy1.16">
当前位置:   article > 正文

cannot import name '_validate_lengths' from 'numpy.lib.arraypad'_skimage numpy1.16

skimage numpy1.16

在import skimage的时候出错:

  1. >>> import skimage
  2. Traceback (most recent call last):
  3. File "<stdin>", line 1, in <module>
  4. File "/opt/AI/AN/lib/python3.7/site-packages/skimage/__init__.py", line 157, in <module>
  5. from .util.dtype import *
  6. File "/opt/AI/AN/lib/python3.7/site-packages/skimage/util/__init__.py", line 8, in <module>
  7. from .arraycrop import crop
  8. File "/opt/AI/AN/lib/python3.7/site-packages/skimage/util/arraycrop.py", line 8, in <module>
  9. from numpy.lib.arraypad import _validate_lengths
  10. ImportError: cannot import name '_validate_lengths' from 'numpy.lib.arraypad' (/opt/AI/AN/lib/python3.7/site-packages/numpy/lib

原因因为与numpy版本不匹配,我的numpy是1.16

可以降低numpy的版本,也可以提高skimage的版本,我最终用的后者,前者会报错:

ValueError: numpy.ufunc has the wrong size, try recompiling. Expected 192, got 216

解决方法:

1)查看版本:

  1. [root@localhost datasets]# pip install scikit-image==9999
  2. Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
  3. ERROR: Could not find a version that satisfies the requirement scikit-image==9999 (from versions: 0.7.2, 0.8.0, 0.8.1, 0.8.2, 0.9.0, 0.9.1, 0.9.3, 0.10.0, 0.10.1, 0.11.2, 0.11.3, 0.12.0, 0.12.1, 0.12.2, 0.12.3, 0.13.0, 0.13.1, 0.14.0, 0.14.1, 0.14.2, 0.14.3, 0.14.4, 0.14.5, 0.15.0, 0.16.1, 0.16.2)
  4. ERROR: No matching distribution found for scikit-image==9999

2)安装最新的

  1. [root@localhost datasets]# pip install scikit-image==0.16.2
  2. Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
  3. Collecting scikit-image==0.16.2
  4. Downloading https://pypi.tuna.tsinghua.edu.cn/packages/dc/48/454bf836d302465475e02bc0468b879302145b07a005174c409a5b5869c7/scikit_image-0.16.2-cp37-cp37m-manylinux1_x86_64.whl (26.5MB)
  5. |████████████████████████████████| 26.5MB 1.8MB/s
  6. Requirement already satisfied: matplotlib!=3.0.0,>=2.0.0 in /opt/AI/AN/lib/python3.7/site-packages (from scikit-image==0.16.2) (2.2.3)
  7. Requirement already satisfied: scipy>=0.19.0 in /opt/AI/AN/lib/python3.7/site-packages (from scikit-image==0.16.2) (1.1.0)
  8. Requirement already satisfied: networkx>=2.0 in /opt/AI/AN/lib/python3.7/site-packages (from scikit-image==0.16.2) (2.1)
  9. Requirement already satisfied: imageio>=2.3.0 in /opt/AI/AN/lib/python3.7/site-packages (from scikit-image==0.16.2) (2.4.1)
  10. Requirement already satisfied: PyWavelets>=0.4.0 in /opt/AI/AN/lib/python3.7/site-packages (from scikit-image==0.16.2) (1.0.0)
  11. Requirement already satisfied: pillow>=4.3.0 in /opt/AI/AN/lib/python3.7/site-packages (from scikit-image==0.16.2) (5.2.0)
  12. Requirement already satisfied: numpy>=1.7.1 in /opt/AI/AN/lib/python3.7/site-packages (from matplotlib!=3.0.0,>=2.0.0->scikit-image==0.16.2) (1.16.0)
  13. Requirement already satisfied: cycler>=0.10 in /opt/AI/AN/lib/python3.7/site-packages (from matplotlib!=3.0.0,>=2.0.0->scikit-image==0.16.2) (0.10.0)
  14. Requirement already satisfied: pyparsing!=2.0.4,!=2.1.2,!=2.1.6,>=2.0.1 in /opt/AI/AN/lib/python3.7/site-packages (from matplotlib!=3.0.0,>=2.0.0->scikit-image==0.16.2) (2.4.5)
  15. Requirement already satisfied: python-dateutil>=2.1 in /opt/AI/AN/lib/python3.7/site-packages (from matplotlib!=3.0.0,>=2.0.0->scikit-image==0.16.2) (2.7.3)
  16. Requirement already satisfied: pytz in /opt/AI/AN/lib/python3.7/site-packages (from matplotlib!=3.0.0,>=2.0.0->scikit-image==0.16.2) (2018.5)
  17. Requirement already satisfied: six>=1.10 in /opt/AI/AN/lib/python3.7/site-packages (from matplotlib!=3.0.0,>=2.0.0->scikit-image==0.16.2) (1.13.0)
  18. Requirement already satisfied: kiwisolver>=1.0.1 in /opt/AI/AN/lib/python3.7/site-packages (from matplotlib!=3.0.0,>=2.0.0->scikit-image==0.16.2) (1.0.1)
  19. Requirement already satisfied: decorator>=4.1.0 in /opt/AI/AN/lib/python3.7/site-packages (from networkx>=2.0->scikit-image==0.16.2) (4.3.0)
  20. Requirement already satisfied: setuptools in /opt/AI/AN/lib/python3.7/site-packages (from kiwisolver>=1.0.1->matplotlib!=3.0.0,>=2.0.0->scikit-image==0.16.2) (41.0.0)
  21. Installing collected packages: scikit-image
  22. Found existing installation: scikit-image 0.14.0
  23. Uninstalling scikit-image-0.14.0:
  24. Successfully uninstalled scikit-image-0.14.0
  25. Successfully installed scikit-image-0.16.2

3)试一下:

  1. [root@localhost datasets]# python
  2. Python 3.7.0 (default, Jun 28 2018, 13:15:42)
  3. [GCC 7.2.0] :: Anaconda, Inc. on linux
  4. Type "help", "copyright", "credits" or "license" for more information.
  5. >>> import skimage
  6. >>>

完全ok

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/IT小白/article/detail/657832
推荐阅读
相关标签