Python问题:Original error was: No module named ‘numpy.core._multiarray_umath‘ 且多次出现cannot import name

 此前系统背景:

win10  

python从3.6.8卸载重装为python3.7

import matplotlib.pyplot as plt
import seaborn as sns
import numpy as np
import pandas as pd

#数据准备
N= 1000
x = np.random.randn(N)
y = np.random.randn(N)
#用Matplotlib 画散点图
plt.scatter(x,y,marker= 'x')
plt.show()

在进行绘图时,出现下述错误

Original error was: No module named 'numpy.core._multiarray_umath'

排查问题:

1.Numpy版本不对

键盘win+R ——出现运行窗口——输入cmd——回车键

C:\Users\DELL>pip show numpy

输入pip show numpy  显示numpy版本

升级numpy版本,出现错误:pip版本太低

C:\Users\DELL>pip install --upgrade numpy
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
Requirement already satisfied: numpy in d:\python\lib\site-packages (1.22.0)
WARNING: You are using pip version 21.3.1; however, version 22.0.3 is available.
You should consider upgrading via the 'D:\python\python.exe -m pip install --upgrade pip' command.

升级pip版本

C:\Users\DELL>python -m pip install -U pip

查看pip版本,升级成功 

C:\Users\DELL>pip show pip

先卸载原先的numpy(为了能使numpy升级)

C:\Users\DELL>pip uninstall numpy

pip重新安装numpy 

C:\Users\DELL>pip install -i https://pypi.tuna.tsinghua.edu.cn/simple numpy

用升级后的pip升级numpy

C:\Users\DELL>pip install --upgrade numpy

重新运行绘图的代码 ,出现下述错误

cannot import name '_c_internal_utils' from 'matplotlib' (D:\python\lib\site...

找原因,可能是因为多次安装卸载Python的不同版本,可能存在多个matplotlib,重新卸载matplotlib库,使用:

pip uninstall matplotlib

然后再重新安装:

pip install matplotlib

 重新运行绘图的代码:

出现下述错误:

 from . import _imaging as core
ImportError: cannot import name '_imaging' from 'PIL' (D:\python\lib\site-packages\PIL\__init__.py)

重新安装Pillow包

C:\Users\DELL>pip uninstall Pillow

C:\Users\DELL>pip install Pillow

运行绘图代码,出现错误

ModuleNotFoundError: No module named 'kiwisolver'

重新安装kiwisolver

pip install kiwisolver

pip install kiwisolver

 出现错误:

ImportError: cannot import name '_ccallback_c' from 'scipy._lib' (D:\python\lib\site-packages\scipy\_lib\__init__.py)

重装scipy

pip uninstall scipy

pip install scipy -i https://pypi.tuna.tsinghua.edu.cn/simple some-package

No module named 'pandas._libs.interval'

 重新安装pandas

C:\Users\DELL>pip install --force-reinstall pandas

再次运行绘图代码,成功了! 

 

  • 17
    点赞
  • 29
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值