此前系统背景:

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

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

 

Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐