简体   繁体   English

为什么我不能在 Python 3.10 上运行 matplotlib?

[英]Why can I not run matplotlib on Python 3.10?

My Issue.我的问题。 I am trying to run matplotlib on python 3.10 on my MacOS, but I get the following error:我试图在我的 MacOS 上运行 matplotlib on python 3.10,但出现以下错误:

ModuleNotFoundError: No module named 'matplotlib'

However, when I try running但是,当我尝试跑步时

pip install matplotlib

then I get back然后我回来

Requirement already satisfied: cycler>=0.10 in ./.local/lib/python3.9/site-packages (from matplotlib) (0.10.0)
Requirement already satisfied: numpy>=1.16 in ./mambaforge/lib/python3.9/site-packages (from matplotlib) (1.21.2)
Requirement already satisfied: kiwisolver>=1.0.1 in ./.local/lib/python3.9/site-packages (from matplotlib) (1.3.2)
Requirement already satisfied: pyparsing>=2.2.1 in ./.local/lib/python3.9/site-packages (from matplotlib) (2.4.7)
Requirement already satisfied: pillow>=6.2.0 in ./.local/lib/python3.9/site-packages (from matplotlib) (8.3.2)
Requirement already satisfied: python-dateutil>=2.7 in ./.local/lib/python3.9/site-packages (from matplotlib) (2.8.2)
Requirement already satisfied: six in ./mambaforge/lib/python3.9/site-packages (from cycler>=0.10->matplotlib) (1.16.0)

Also, in response to另外,为了回应

python3 --version

terminal says终端说

Python 3.9.6

Also, I am able to use matplotlib just fine if I compile my code using Python 2.7.16 on Sublime Text 3.此外,如果我在 Sublime Text 3 上使用 Python 2.7.16 编译我的代码,我就可以很好地使用 matplotlib。

My Question.我的问题。 How can I get matplotlib to run on Python 3.10?如何让 matplotlib 在 Python 3.10 上运行?

Since I am still new to Python (or to programming, for that matter), please let me know if I should provide additional information.由于我对 Python(或编程,就此而言)仍然是新手,请让我知道是否需要提供更多信息。

Note: I have already looked at this and this , but I couldn't fix the issue.注意:我已经看过thisthis ,但我无法解决问题。

I have had the same issue.我有同样的问题。 It wasn't only for MatPlotLib, but Pandas and NumPy.它不仅适用于 MatPlotLib,还适用于 Pandas 和 NumPy。

From seeing what the terminal tried to do, it seems that 3rd party libraries are not "compatible" yet.从终端试图做的事情来看,第 3 方库似乎还不“兼容”。 I am using my older version of python now.我现在正在使用旧版本的 python。

When trying to get the libs, it just scrolled through all the versions of matplotlib, and gave errors.尝试获取库时,它只是滚动了所有版本的 matplotlib,并给出了错误。 It might take some time before this is resolved.解决此问题可能需要一些时间。

I recently experienced this problem after installing Python 3.10.我最近在安装 Python 3.10 后遇到了这个问题。

Use version Python 3.9.使用 Python 3.9 版本。 That worked for me, but I can't figure out how to install matplotlib on 3.9 via the command line, but I'm using PyCharm right now, so I got it to work on there.这对我有用,但我不知道如何通过命令行在 3.9 上安装 matplotlib,但我现在正在使用 PyCharm,所以我让它在那里工作。

proof of installation安装证明

If you figure out how to install it via the command line, let me know!如果您知道如何通过命令行安装它,请告诉我! I'm using two versions of Python.我正在使用两个版本的 Python。 I would like to know how to do it as well.我也想知道怎么做。 I'm sure I can find it eventually.我相信我最终能找到它。 I believe if you uninstall Python 3.10 and leave only 3.9, it will work.我相信如果你卸载 Python 3.10 并只留下 3.9,它会起作用。

I found a temporary (unstable) fix for anyone desperate to run matplotlib (and many other packages, eg numba, scikit-learn, scipy, etc.) on Python 3.10 for Windows 10, as described by Amit Thinks .Amit Thinks 所述,我为任何渴望在 Windows 10 的 Python 3.10 上运行 matplotlib(以及许多其他软件包,例如 numba、scikit-learn、scipy 等)的人找到了一个临时(不稳定)修复程序。 Amit uses a source of unstable binaries curated by Christoph Gohlke at UC Irvine, so these are likely not malware infested. Amit 使用了由加州大学欧文分校的Christoph Gohlke策划的不稳定二进制文件的来源,因此这些文件很可能没有被恶意软件感染。

I faced the same issue , while trying to install matplotlib for python 3.10 .我在尝试为 python 3.10 安装 matplotlib 时遇到了同样的问题。 i faced 2 issues我遇到了 2 个问题

1)It said wheel module not installed (installed via running pip install wheel) 1)它说没有安装轮子模块(通过运行 pip install wheel 安装)

2)It said it required microsoft visual c++ 14.0+ (it was already present when checked in control panel(x64)) (after installing wheel module while running the code[pip install matplotlib] for 3rd time). 2)它说它需要microsoft visual c ++ 14.0+(在控制面板(x64)中检查时它已经存在)(在第三次运行代码[pip install matplotlib]安装wheel模块之后)。 asked me to download visual studio community 2019 and build tools.... Did so.让我下载 Visual Studio Community 2019 并构建工具.... 这样做了。

And now i was able install matplotlib in python 3.10 and runs fine (when cheking in control panel there was another visual c++ 14.0+ installed (x86) along with (x64),dont know why it works only when x86 version of visual c++ is installed.现在我能够在 python 3.10 中安装 matplotlib 并且运行良好(在控制面板中检查时,安装了另一个 Visual c++ 14.0+(x86)和(x64),不知道为什么它只在安装 x86 版本的 Visual c++ 时才有效.

I had same issues with matplotlib,pandas,numpay etc on python 3.10 on window 10. I install with windows binaries packages .我在 windows 10 上的 python 3.10 上遇到了 matplotlib、pandas、numpay 等同样的问题。我使用 windows 二进制安装。

after download "matplotlib‑3.4.3‑cp310‑cp310‑win_amd64.whl" use this commond:下载“matplotlib‑3.4.3‑cp310‑cp310‑win_amd64.whl”后使用这个command:

pip install matplotlib-3.4.3-cp310-cp310-win_amd64.whl

如果您使用的是 conda 环境:

conda install -c conda-forge matplotlib

I think it does run on Python 3.10.我认为它确实在 Python 3.10 上运行。 When you are quering for a graph or plot, do this当您查询图表或 plot 时,请执行此操作

import matplotlib.pyplot as plt导入 matplotlib.pyplot 作为 plt

Do review me guys.做审查我的家伙。

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

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