【问题标题】:ModuleNotFoundError: No module named 'matplotib' [closed]ModuleNotFoundError:没有名为“matplotlib”的模块[关闭]
【发布时间】:2021-08-23 16:18:00
【问题描述】:

我已经使用pip install matplotlib 下载了 matplotlib 模块,但是出现了这个错误

Traceback (most recent call last):
  File "c:/Users/good pc/Documents/Jarvis/Machine_learning_model.py", line 3, in <module>
    import matplotib.pyplot as plt
ModuleNotFoundError: No module named 'matplotib'

如果需要,我已经编写了此代码

import pandas as pd 
import numpy as np 
import matplotib.pyplot as plt 

a = pd.read_csv("iris.csv")

pd.head() 

我不知道为什么会出现这个错误,因为我的 vscode 中已经下载了 matplotlib。

python 版本 3.7.3

提前致谢!!!

【问题讨论】:

  • 这是一个错字.....你在matplotib中缺少l,因为它的名字是matplotlib所以写import matplotlib.pyplot as plt

标签: python-3.x pandas matplotlib pip modulenotfounderror


【解决方案1】:
import pandas as pd 
import numpy as np 
import matplotlib.pyplot as plt 

a = pd.read_csv("iris.csv")

""" The pandas module has no function pd.head().
You can only call .head() on e.g.
a DataFrame of pandas so in this case you need to use a.head()"""

#pd.head()

【讨论】:

  • AttributeError: module "pandas" has no attribute "head"
  • 熊猫模块没有提问者使用的函数 pd.head() 。您只能调用 .head() 例如pandas 的 DataFrame 所以在这种情况下你需要使用 a.head()
  • 是的,我试图回答受错字影响的问题错误,顺便感谢熊猫方法的更正,您更正了下一级错误:))。
猜你喜欢
  • 2017-07-08
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-05-30
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多