【问题标题】:Matplotlib.pylot says 'requirement already satisfied' but also 'Module not found' [closed]Matplotlib.pyplot 说“要求已经满足”,但也说“未找到模块”[关闭]
【发布时间】:2020-10-22 01:41:49
【问题描述】:

这与我之前提出的问题类似,但我不明白发生了什么。我在 Windows 上使用 pip 20.2.3python 3.8.2

之前,当我在 cmd 中输入 pip install matplotlibpip3 install matplotlib 时,我会收到一条消息,说所有“要求都已满足”。但是当我在 VSCode 上运行 import matplotlib.pylot as plt 时,它告诉我

Traceback (most recent call last):
  File "c:/Users/sound/Desktop/now/Trade Simulation/#2/Trade Simulation.py", line 6, in <module>
    import matplotlib.pylot as plt
ModuleNotFoundError: No module named 'matplotlib.pylot'

不仅如此,我最近刚刚将 pip 从20.2.3 更新为20.2.4。当我运行相同的命令pip install matplotlib 时,我没有像以前那样说“满足要求”,而是收到一条红色的大量错误消息,如下所示:

    ERROR: Command errored out with exit status 1:
     command: 'c:\users\sound\appdata\local\programs\python\python39\python.exe' -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\sound\\AppData\\Local\\Temp\\pip-install-9w_lvhnf\\matplotlib\\setup.py'"'"'; __file__='"'"'C:\\Users\\sound\\AppData\\Local\\Temp\\pip-install-9w_lvhnf\\matplotlib\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base 'C:\Users\sound\AppData\Local\Temp\pip-pip-egg-info-ihoi_gsj'
         cwd: C:\Users\sound\AppData\Local\Temp\pip-install-9w_lvhnf\matplotlib\
    Complete output (249 lines):
    WARNING: The wheel package is not available.
        ERROR: Command errored out with exit status 1:
         command: 'c:\users\sound\appdata\local\programs\python\python39\python.exe' 'c:\users\sound\appdata\local\programs\python\python39\lib\site-packages\pip\_vendor\pep517\_in_process.py' prepare_metadata_for_build_wheel 'C:\Users\sound\AppData\Local\Temp\tmpsqdka5ne'

当我更新 pip 时输出的变化有点让我失望。我不确定该怎么做或如何解决此安装错误。任何见解将不胜感激。

使用pip3.8 install -U matplotlib 会回复我

ERROR: Could not install packages due to an EnvironmentError: [WinError 5] Access is denied: 'C:\\Users\\12132\\AppData\\Local\\Programs\\Python\\Python38-32\\Lib\\site-packages\\~atplotlib\\ft2font.cp38-win32.pyd'
Consider using the `--user` option or check the permissions.

【问题讨论】:

  • 您的错误表明有错字:import matplotlib.pylot as plt 应该是 import matplotlib.pyplot as plt

标签: python matplotlib import module


【解决方案1】:

您的错误表示拼写错误,matplotlib 中没有模块 pylot

您拥有的导入:

import matplotlib.pylot as plt

应该是:

import matplotlib.pyplot as plt

【讨论】:

  • 哇,我真的把所有的时间都花在了这么小的事情上。谢谢!我自己也想不通
  • 很高兴为您提供帮助。无法告诉你有多少次一个错字把我拖进了兔子洞。
【解决方案2】:

如果您有多个 python 安装,请使用 pipVersion.exe(如 pip3.7.exe)安装matplotlib。在 linux 中还有一件事,在 shebang 中添加解释器的完整路径。

【讨论】:

  • 我很抱歉,但我不太明白你在说什么
  • 对于每个 python 安装,您将在 Scripts 文件夹中获得一个 pip.exe 附加版本名称,如 pip3.8.exe。使用它来安装
  • 如果我更新了python,它还会追加pip吗?
  • 使用pip3.8 install -U matplotlib更好
  • 我编辑了我的帖子,因为我遇到了另一个错误。这个虽然是新的
猜你喜欢
  • 1970-01-01
  • 2018-01-02
  • 2019-02-08
  • 2022-06-17
  • 2020-08-13
  • 2021-01-31
  • 2013-01-17
  • 2022-07-02
  • 1970-01-01
相关资源
最近更新 更多