简体   繁体   English

将Tcl / Tk链接到Python 2.5

[英]Linking Tcl/Tk to Python 2.5

I have an existing Python 2.4 and it is working properly with tkinter as I tested it using 我有一个现有的Python 2.4,并且在我使用tkinter对其进行测试时可以正常使用

python 蟒蛇

import _tkinter 导入_tkinter

import Tkinter Tkinter._test() 导入Tkinter Tkinter._test()

Now, I have installed python 2.5.2 but when I try the same tests (with the newer version), it returns (but the same tests are working for the previous version) 现在,我已经安装了python 2.5.2,但是当我尝试相同的测试(使用较新的版本)时,它会返回(但相同的测试适用于先前的版本)

ImportError: No module named _tkinter ImportError:没有名为_tkinter的模块

I know that tcl8.5 and tk8.5 are installed on my machine as the following commands return there locations 我知道tcl8.5和tk8.5已安装在我的机器上,因为以下命令返回了位置

whereis tcl tcl: /usr/lib/tcl8.4 /usr/local/lib/tcl8.5 /usr/local/lib/tcl8.4 /usr/share/tcl8.4 tcl tcl在哪里:/usr/lib/tcl8.4 /usr/local/lib/tcl8.5 /usr/local/lib/tcl8.4 /usr/share/tcl8.4

whereis tk tk: /usr/lib/tk8.4 /usr/local/lib/tk8.5 /usr/share/tk8.4 where tk tk:/usr/lib/tk8.4 /usr/local/lib/tk8.5 /usr/share/tk8.4

Any ideas how do I make my newer python version work with tkinter? 任何想法如何使我的新python版本与tkinter一起使用?

The files you found are for linking directly to tcl/tk. 找到的文件用于直接链接到tcl / tk。 Python depends on another library as well: _tkinter.so. Python也依赖于另一个库:_tkinter.so。 It should be in /usr/lib/python2.5/lib-dynload/_tkinter.so. 它应该在/usr/lib/python2.5/lib-dynload/_tkinter.so中。
How did you install python2.5? 您如何安装python2.5? If you are using Debian or Ubuntu you need to install the python-tk package to get Tkinter support. 如果您使用的是Debian或Ubuntu,则需要安装python-tk软件包以获得Tkinter支持。

If the _tkinter.so file is there, your environment could be causing problems. 如果存在_tkinter.so文件,则您的环境可能会引起问题。 If 如果

python -E -c "import Tkinter;Tkinter._test()" python -E -c“ import Tkinter; Tkinter._test()”

suceeds, but 导致,但是

python -c "import Tkinter;Tkinter._test()" python -c“ import Tkinter; Tkinter._test()”

fails, then the problem is with how your environment is set up. 失败,则问题出在环境设置上。 Check the value of PYTHONPATH is set correctly. 检查PYTHONPATH的值是否设置正确。

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

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