python - 无法在 Python 3.10 上安装 Matplotlib

标签 python matplotlib

python3.10 -m pip install --user matplotlib

当我运行以上安装 Matplotlib 时,我不断收到以下错误。我最初遇到 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 目前不支持 Python 3.10,因此您有以下选择。

  1. 查看 answer有关降级到 Python 3.9 的详细说明。
  2. 安装支持 Python 3.10 的 Matplotlib 预发布版本。这可以通过命令 pip install matplotlib==3.5.0rc1 来完成(我建议这样做)。

关于python - 无法在 Python 3.10 上安装 Matplotlib,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69791864/

相关文章:

python - 当 requirements.txt 或 setup.py 改变时用 tox 重新安装 virtualenv

python - 自定义回溯输出

python - 通过自定义排序规则对数据框行重新排序

python - 无法标记多行 sns.catplot()

python - 如何填充 matplotlib 网格?

python - pythonivot_table 的替代方案,用于两个变量的频率表

python - 在python中使用计算函数自动填充

python - 有没有办法在 VSCode 的新窗口中打开图形?

matplotlib - matplotlib 条形图中奇怪的空白,具有 > 140 个值

python - matplotlib 平均区间图