gpt4 book ai didi

Python3.5 backend_tkagg 不再可用?

转载 作者:行者123 更新时间:2023-11-28 21:48:02 25 4
gpt4 key购买 nike

我正在尝试运行之前正在运行的应用程序。它曾经在 Ubuntu 和 Windows 7 上运行。我现在有一台 Windows 10 机器,代码失败了。可能是因为我现在使用的是 python 3.5,但坦率地说,我不记得我在其他机器(不再可用)上使用的是什么。

关键行是:

import matplotlib
matplotlib.use("TkAgg")
from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg, NavigationToolbar2TkAgg

前段时间已经从各个地方解除了。但是,现在当我运行它时,它会抛出一个错误:

Traceback (most recent call last):
File "C:\....py", line 17, in <module>
from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg, NavigationToolbar2TkAgg
File "C:\Users\...\AppData\Local\Programs\Python\Python35-32\lib\site-packages\matplotlib\backends\backend_tkagg.py", line 13, in <module>
import matplotlib.backends.tkagg as tkagg
File "C:\Users\g...\AppData\Local\Programs\Python\Python35-32\lib\site-packages\matplotlib\backends\tkagg.py", line 9, in <module>
from matplotlib.backends import _tkagg
ImportError: DLL load failed: The specified module could not be found.

在交互式 session 中,似乎是第三行失败了:

>>> import matplotlib
>>> matplotlib.use("TkAgg")
>>> from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg, NavigationToolbar2TkAgg
Traceback (most recent call last):
File "<pyshell#4>", line 1, in <module>
from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg, NavigationToolbar2TkAgg
File "C:\Users\...\AppData\Local\Programs\Python\Python35-32\lib\site-packages\matplotlib\backends\backend_tkagg.py", line 13, in <module>
import matplotlib.backends.tkagg as tkagg
File "C:\Users\...\AppData\Local\Programs\Python\Python35-32\lib\site-packages\matplotlib\backends\tkagg.py", line 9, in <module>
from matplotlib.backends import _tkagg
ImportError: DLL load failed: The specified module could not be found.

我试过了

pip uninstall matplotlib
pip install matplotlib

在命令提示符下,但错误仍然存​​在。

似乎有一个 python-matplotlib-tk 包,但我不确定这是什么。

我应该回到 python 3.4,还是有解决方案?这是一个已知问题吗?


回应以下关于安装 matplotlib 的评论:

C:\>pip install matplotlib
Collecting matplotlib
Downloading matplotlib-1.5.1-cp35-none-win32.whl (6.2MB)
100% |################################| 6.2MB 67kB/s
Requirement already satisfied (use --upgrade to upgrade): numpy>=1.6 in c:\users\...\appdata\local\programs\python\python35-32\lib\site-packages (from matplotlib)
Requirement already satisfied (use --upgrade to upgrade): pytz in c:\users\...\appdata\local\programs\python\python35-32\lib\site-packages (from matplotlib)
Requirement already satisfied (use --upgrade to upgrade): python-dateutil in c:\users\...\appdata\local\programs\python\python35-32\lib\site-packages (from matplotlib)
Requirement already satisfied (use --upgrade to upgrade): cycler in c:\users\...\appdata\local\programs\python\python35-32\lib\site-packages (from matplotlib)
Requirement already satisfied (use --upgrade to upgrade): pyparsing!=2.0.4,>=1.5.6 in c:\users\...\appdata\local\programs\python\python35-32\lib\site-packages (from matplotlib)
Requirement already satisfied (use --upgrade to upgrade): six>=1.5 in c:\users\...\appdata\local\programs\python\python35-32\lib\site-packages (from python-dateutil->matplotlib)
Installing collected packages: matplotlib
Successfully installed matplotlib-1.5.1

最佳答案

我遇到了同样的问题

我阅读了 matplotlib 中的文档

For Python 3.5 the Visual C++ Redistributable for Visual Studio 2015 needs to be installed. In case Python 2.7 to 3.4 are not installed for all users (not the default), the Microsoft Visual C++ 2008 ( 64 bit or 32 bit for Python 2.7 to 3.2) or Microsoft Visual C++ 2010 ( 64 bit or 32 bit for Python 3.3 and 3.4) redistributable packages need to be installed.

然后我安装了the Visual C++ Redistributable for Visual Studio 2015解决了问题

关于Python3.5 backend_tkagg 不再可用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35805809/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com