$ pip3 install matplotlib
Requirement already satisfied: matplotlib in /home/vorac/.local/lib/python3.7/site-packages (3.0.3)
Requirement already satisfied: cycler>=0.10 in /home/vorac/.local/lib/python3.7/site-packages (from matplotlib) (0.10.0)
Requirement already satisfied: python-dateutil>=2.1 in /home/vorac/.local/lib/python3.7/site-packages (from matplotlib) (2.8.0)
Requirement already satisfied: pyparsing!=2.0.4,!=2.1.2,!=2.1.6,>=2.0.1 in /home/vorac/.local/lib/python3.7/site-packages (from matplotlib) (2.3.0)
Requirement already satisfied: numpy>=1.10.0 in /home/vorac/.local/lib/python3.7/site-packages (from matplotlib) (1.16.3)
Requirement already satisfied: kiwisolver>=1.0.1 in /home/vorac/.local/lib/python3.7/site-packages (from matplotlib) (1.1.0)
Requirement already satisfied: six in /usr/lib/python3/dist-packages (from cycler>=0.10->matplotlib) (1.12.0)
Requirement already satisfied: setuptools in /usr/lib/python3/dist-packages (from kiwisolver>=1.0.1->matplotlib) (40.8.0)
都好。现在:
$ python3
Python 3.7.3rc1 (default, Mar 13 2019, 11:01:15)
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import matplotlib
>>>
>>>
>>> import matplotlib.pyplot as plt
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/vorac/.local/lib/python3.7/site-packages/matplotlib/pyplot.py", line 2372, in <module>
switch_backend(rcParams["backend"])
File "/home/vorac/.local/lib/python3.7/site-packages/matplotlib/pyplot.py", line 207, in switch_backend
backend_mod = importlib.import_module(backend_name)
File "/usr/lib/python3.7/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "/home/vorac/.local/lib/python3.7/site-packages/matplotlib/backends/backend_tkagg.py", line 1, in <module>
from . import _backend_tk
File "/home/vorac/.local/lib/python3.7/site-packages/matplotlib/backends/_backend_tk.py", line 5, in <module>
import tkinter as Tk
ModuleNotFoundError: No module named 'tkinter'
诡异的。
$ pip3 install tkinter
Collecting tkinter
Could not install packages due to an EnvironmentError: 404 Client Error: Not Found for url: https://pypi.org/simple/tkinter/
该页面实际上只包含文本“404 Not Found”。在这种情况下我该怎么办呢。我正在尝试将软件包安装到本地 $HOME,但系统范围的安装也可以工作。
答案1
由于您使用的是 Debian,并且您感兴趣的模块可以作为软件包提供,因此我们可以使用它们来解决您的问题。在这种情况下,使用模块的一部分需要另一个模块,而该模块不属于第一个严格依赖项的一部分,那么可能有一个可选的依赖项可以解决您的问题;的包matplotlib
是python3-matplotlib
,所以
apt show python3-matplotlib
将告诉我们为此模块推荐或建议哪些可选依赖项。在这种情况下,python3-tk
被列出并且似乎是一个可能的候选者,这得到了确认
apt show python3-tk
所以
sudo apt install python3-tk
应该可以解决你的问题。