Matplotlib.pylot表示“已满足要求”,但也表示“未找到模块”

2024-06-16 10:28:37 发布

您现在位置:Python中文网/ 问答频道 /正文

这是一个类似于我以前问过的问题,但我不明白发生了什么。我正在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.

Tags: installpippyimportmatplotliblocalerrorusers
2条回答

您的错误表明键入错误,matplotlib中没有模块pylot

您拥有的导入:

import matplotlib.pylot as plt

应该是:

import matplotlib.pyplot as plt

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

相关问题 更多 >