【发布时间】:2021-04-09 16:27:36
【问题描述】:
我在新安装的 Ubuntu(Ubuntu 20.04.1 LTS)上遇到了 Python 3.9.1 的问题 - 在运行任何基于 tkinter 的应用程序时,我收到导入错误(来自 python 控制台的示例):
user@ubuntu:~$ python3
Python 3.9.1 (default, Dec 29 2020, 13:25:02)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import tkinter
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/linuxbrew/.linuxbrew/Cellar/python@3.9/3.9.1_3/lib/python3.9/tkinter/__init__.py", line 37, in <module>
import _tkinter # If this fails your Python may not be configured for Tk
ModuleNotFoundError: No module named '_tkinter'
我知道这个问题在 SO 和其他互联网资源中已多次讨论,几天来我正在尝试所有选项和解决方案(如 this、this、another one、brew forum 他们都没有解决问题)。
什么有效 - 只有卸载自制软件才能解决问题。仍然希望配置所有内容以使用自制软件。
我尝试过/执行过的操作:
- 修复了所有
brew doctor报告的问题:
Your system is ready to brew.
- tcl-tk 在
brew list下列出:
black hello libx11 libxdmcp openssl@1.1 pylint sqlite xorgproto
bzip2 libffi libxau libxext patchelf python@3.9 tcl-tk xz
gdbm libpthread-stubs libxcb ncurses pkg-config readline unzip zlib
-
执行
brew uninstall python和brew install python -
最初的想法是诗歌和/或 pyenv 打破了依赖关系,目前没有使用它们。
我不是 ubuntu 的铁杆用户,我错过了什么吗?任何想法或帮助都会很有价值。
【问题讨论】:
-
你为什么不使用 apt 而不是 homebrew
-
没有硬性原因 - 只是在 mac 上的工作环境中习惯了它。它运行良好,除了 tkinter 的问题。
标签: python python-3.x ubuntu tkinter homebrew