Python 版本和 Tcl/Tk 兼容性
我已经安装了 Tcl 和 Tk,并且遇到了熟悉的“没有名为 _tkinter 的模块”错误。
我的“python”Bash 命令运行 Python 版本 2.4.2,但 Synaptic 说我有 2.6。 6已安装。我什至尝试安装3.0,但也失败了。
我自己配置并构建了 Tcl/Tk tarball,并尝试使用 synaptic 包。
“wish”和“tclsh”命令都有效,所以我知道模块已安装,但我无法让 Python 识别它们。此外,我一生都无法弄清楚我应该使用哪个版本的 Python 以及如何让我的 Bash 命令使用该版本。
我没有看到任何删除 2.4.2 的选项,如果我删除 2.6.6,它会删除似乎是我的大多数其他软件包的内容(我知道这很夸张)。
我真的不知道从这里去哪里,所以任何指导将不胜感激。
更新:
我必须重新安装 python-tk 包,2.6 可以导入它。现在我只需要弄清楚如何删除 2.4,以免以后搞砸。
I have installed Tcl and Tk, and I am running into the oh-so-familiar "No module named _tkinter" error.
My 'python' Bash command runs Python version 2.4.2, but Synaptic says I have 2.6.6 installed. I even tried installing 3.0, but that also failed.
I have configured and built the Tcl/Tk tarballs myself, and tried using the synaptic packages.
Both "wish" and "tclsh" commands work, so I know that the modules are installed, but I can't for the life of me get Python to recognize them. Moreover, I can't for the life of my figure out which version of Python I should be using and how to get my Bash command to use that one.
I don't see any options for 2.4.2 removal, and if I remove 2.6.6, it removes what seems to be most of my other packages (exaggeration, I know).
I really don't know where to go from here, so any guidance would be greatly appreciated.
Update:
I had to reinstall the python-tk package, and 2.6 is able to import it. Now I just need to figure out how to remove 2.4 for the sake of not screwing something up later on.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这里有一些命令可以帮助您诊断问题。
首先,尝试运行附加版本号的
python
命令。自从Synaptic 表示您已安装 2.6.6,您应该能够运行 python2.6 来
获取该版本:
如果您仍然无法运行 TK,请找到
_tkinter.so
模块所在的位置你的系统。它可能在 2.6.6 解释器找不到的地方。以下是 Ubuntu Lucid 上
python-tk
软件包的安装位置:Here are a few commands which could help you diagnose your problem.
First, try to run the
python
command with the version number appended. SinceSynaptic says you have 2.6.6 installed you should be able to run
python2.6
toget that version:
If you still can't get TK to run, find where the
_tkinter.so
module lives onyour system. It may be somewhere the 2.6.6 interpreter can't find it. Here's the location as installed by
python-tk
package on Ubuntu Lucid:只是为那些登陆此页面的人提供有关 Python 3+ 的更新(就像我一样)。要在基于 Debian 的 Linux (Ubuntu) 上运行
tkinter
,需要python3
以及python3-tk
(它不在库中) list):另外,脚本需要将其作为第一行:
至少这是我解决问题的方法。
Just an update for those who land on this page, regarding Python 3+ (like I have). To run
tkinter
on a Debian-based Linux (Ubuntu),python3
is needed, as well aspython3-tk
(it's not in the library list):Also, the script needs to have this as the first line:
At least that is how I solved the problem.