ImportError: numpy.core.multiarray failed to import

问题:

ImportError: numpy.core.multiarray failed to import

分析:

从我python脚本的执行发现报错

, in <module>
    from sklearn.metrics import *
  File "/home/jie/anaconda3/lib/python3.11/site-packages/sklearn/__init__.py", line 82, in <module>
    from .base import clone
  File "/home/jie/anaconda3/lib/python3.11/site-packages/sklearn/base.py", line 17, in <module>
    from .utils import _IS_32BIT
  File "/home/jie/anaconda3/lib/python3.11/site-packages/sklearn/utils/__init__.py", line 17, in <module>
    from scipy.sparse import issparse
  File "/home/jie/anaconda3/lib/python3.11/site-packages/scipy/sparse/__init__.py", line 267, in <module>
    from ._csr import *
  File "/home/jie/anaconda3/lib/python3.11/site-packages/scipy/sparse/_csr.py", line 10, in <module>
    from ._sparsetools import (csr_tocsc, csr_tobsr, csr_count_blocks,
ImportError: numpy.core.multiarray failed to import

里面提到scipy这个库调用numpy报错的,说明不兼容

然后更新numpy的时候提示

scipy与numpy==1.16.4兼容

于是安装numpy==1.16.4

解决方法:

pip install numpy==1.16.4

上一篇:面向切面编程 JoinPoint 获取 方法签名、方法参数、目标对象 等


下一篇:软件测试基础十五(python 面向对象)