ImportError: cannot import name '_validate_lengths' 解决方法
程序员文章站
2022-04-25 21:19:12
...
numpy升级以后遇到以上错误,版本变化函数名称发生变化:根据错误提示点击到D:\Program Files (x86)\Anaconda3\Lib\site-packages\skimage\util\arraycrop.py文件
加入下面语句
修改前:
-
import numpy as np
-
from numpy.lib.arraypad import _validate_lengths
修改后
-
import numpy as np
-
from distutils.version import LooseVersion as Version
-
old_numpy = Version(np.__version__) < Version('1.16')
-
if old_numpy:
-
from numpy.lib.arraypad import _validate_lengths
-
else:
-
from numpy.lib.arraypad import _as_pairs
即可解决问题。
上一篇: LeetCode(1232 缀点成线)
推荐阅读
-
pycharm读取图片,提示ImportError: cannot import name imread解决方法
-
ImportError: cannot import name 'cross_validation' from 'sklearn'
-
cannot import name 'Flask' from 'flask'
-
ImportError: cannot import name 'Optional'
-
Python中使用Enum类时出现cannot import name ‘Enum‘ from partially initialized module ‘enum‘
-
cannot import name ‘Graph‘ from ‘pyecharts‘
-
解决pyecharts importerror问题:cannot import name ‘bar’ from pyecharts
-
ImportError: cannot import name ‘Bar‘ from ‘pyecharts‘ (D:\Anaconda3-2019.03\Anaconda3\lib\site-pack
-
2021-06-13cannot import name ‘Bar‘ from ‘pyecharts.charts‘ (C:\Users\SieburgShen\AppData\Roaming\Pyt
-
解决pyecharts导包报错 cannot import name 'Bar