简体   繁体   English

无法在 Python 3.10 上安装 Matplotlib

[英]Cannot install Matplotlib on Python 3.10

python3.10 -m pip install --user matplotlib

I keep getting the following error when I run the above to install Matplotlib.当我运行上面的程序来安装 Matplotlib 时,我不断收到以下错误。 I was initially getting a C++ error and I installed Visual Studio.我最初遇到 C++ 错误,我安装了 Visual Studio。

Time Elapsed 00:00:00.36
    error: command 'C:\\Windows\\Microsoft.NET\\Framework\\v4.0.30319\\msbuild.exe' failed with exit code 1
    ----------------------------------------
ERROR: Command errored out with exit status 1:
'C:\Users\HP\AppData\Local\Microsoft\WindowsApps\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\python.exe' -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\HP\\AppData\\Local\\Temp\\pip-install-zq_i4lrq\\matplotlib_ce44358747c74e83a93eefbdd122f13e\\setup.py'"'"'; __file__='"'"'C:\\Users\\HP\\AppData\\Local\\Temp\\pip-install-zq_i4lrq\\matplotlib_ce44358747c74e83a93eefbdd122f13e\\setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\HP\AppData\Local\Temp\pip-record-yvrkad5m\install-record.txt' --single-version-externally-managed --user --prefix= --compile --install-headers 'C:\Users\HP\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\Include\matplotlib'
Check the logs for full command output.

Matplotlib doesn't support Python 3.10 at the moment, so you have the following options. Matplotlib 目前不支持 Python 3.10,因此您有以下选择。

  1. Downgrade to Python 3.9.降级到 Python 3.9。
  2. Install the pre-release version of Matplotlib which does support Python 3.10.安装支持 Python 3.10 的 Matplotlib 预发布版本。 This can be done with the command pip install matplotlib==3.5.0rc1 (and is what I would recommend doing).这可以通过命令pip install matplotlib==3.5.0rc1来完成(我建议这样做)。

I have been having the same problem for a while now.我已经有一段时间遇到同样的问题了。 Another answer I found was here: Error trying to install matplotlib in Windows我在这里找到的另一个答案是: 尝试在 Windows 中安装 matplotlib 时出错

In summary, pip install --pre matplotlib also works.总之, pip install --pre matplotlib也有效。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM