python无法import matplotlib怎么办?
>>>importmatplotlibTraceback(mostrecentcalllast):File"<pyshell#1>",line1,in<module>im...
>>> import matplotlib
Traceback (most recent call last):
File "<pyshell#1>", line 1, in <module>
import matplotlib
File "C:\Users\ME\AppData\Roaming\Python\Python38\site-packages\matplotlib\__init__.py", line 138, in <module>
from . import cbook, rcsetup
File "C:\Users\ME\AppData\Roaming\Python\Python38\site-packages\matplotlib\cbook\__init__.py", line 31, in <module>
import numpy as np
File "C:\Users\ME\AppData\Roaming\Python\Python38\site-packages\numpy\__init__.py", line 150, in <module>
from . import random
File "C:\Users\ME\AppData\Roaming\Python\Python38\site-packages\numpy\random\__init__.py", line 143, in <module>
from .mtrand import *
File "type.pxd", line 9, in init mtrand
ValueError: builtins.type size changed, may indicate binary incompatibility. Expected 880 from C header, got 864 from PyObject 展开
Traceback (most recent call last):
File "<pyshell#1>", line 1, in <module>
import matplotlib
File "C:\Users\ME\AppData\Roaming\Python\Python38\site-packages\matplotlib\__init__.py", line 138, in <module>
from . import cbook, rcsetup
File "C:\Users\ME\AppData\Roaming\Python\Python38\site-packages\matplotlib\cbook\__init__.py", line 31, in <module>
import numpy as np
File "C:\Users\ME\AppData\Roaming\Python\Python38\site-packages\numpy\__init__.py", line 150, in <module>
from . import random
File "C:\Users\ME\AppData\Roaming\Python\Python38\site-packages\numpy\random\__init__.py", line 143, in <module>
from .mtrand import *
File "type.pxd", line 9, in init mtrand
ValueError: builtins.type size changed, may indicate binary incompatibility. Expected 880 from C header, got 864 from PyObject 展开
3个回答
展开全部
matplotlib作为第三方库,需要安装后才能使用。在cmd中输入pip install matplotlib
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
import前面多个空格
追问
老铁你看Traceback了么,空格是复制的时候就有的
追答
看到了 你上面报错之后你还接着往下写我还以为你根本不在乎那个报错呢
关于那里解决方法众说纷纭,我建议最简单的方法就是用pycharm等IDE导入一次这个包
啥都解决了
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
应该是创建项目导致的环境变量的问题,导致模块没法导入
import sys
import os
print(sys.path) #查看当前解项目的环境变量
sys.path.append(os.path.dirname(os.path.abspath(__file__)))#加环境变量
print(sys.path)#再查看
import matplotlib
import sys
import os
print(sys.path) #查看当前解项目的环境变量
sys.path.append(os.path.dirname(os.path.abspath(__file__)))#加环境变量
print(sys.path)#再查看
import matplotlib
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询