简体   繁体   English

我无法在 termux 上安装 tkinter

[英]I can't install tkinter on termux

I installed termux on my android device (Pixel C), and successfully installed python 3.6.2 there, and after downloaded (with pip) some libraries like pillow (there were some problems, but with online forums I solved it), vk, etc. Tkinter should be preinstalled on python, but it wasn't (like some other modules like time, random etc.).我在我的 android 设备(Pixel C)上安装了 termux,并在那里成功安装了 python 3.6.2,并在下载(使用 pip)一些库后(有一些问题,但我通过在线论坛解决了它)、vk 等. Tkinter 应该预装在 python 上,但它不是(像其他一些模块,如时间、随机等)。 All this modules - tkinter, that should be preinstalled, are not there - and it is not possible to install them.所有这些模块 - 应该预装的 tkinter 都不在那里 - 并且无法安装它们。 pip install tkinter ->Could not find a version that satisfies the requirement time (from versions: ) No matching distribution found for tkinter. pip install tkinter -> 找不到满足要求时间的版本(来自版本:)找不到与 tkinter 匹配的发行版。 if I try with: apt-get install python3-tk Still nothing - error placing file.如果我尝试: apt-get install python3-tk 仍然没有 - 放置文件时出错。 apt-get update and apt upgrade didn't help... apt-get update 和 apt upgrade 没有帮助...

To install tkinter in Termux just simply do:要在 Termux 中安装 tkinter,只需执行以下操作:

pkg install python-tkinter

As mentioned here: https://github.com/termux/x11-packages/issues/172#issuecomment-554781785正如这里提到的: https : //github.com/termux/x11-packages/issues/172#issuecomment-554781785

Checking your Tkinter support检查您的 Tkinter 支持

A good way to systematically check whether your Tkinter support is working is the following.系统检查您的 Tkinter 支持是否有效的好方法如下。

Enter an interactive Python interpreter in a shell on an X console.在 X 控制台的 shell 中输入交互式 Python 解释器。

Step 1 - can _tkinter be imported?第 1 步 - 可以导入 _tkinter 吗?

Try the following command at the Python prompt:在 Python 提示符下尝试以下命令:

import _tkinter # with underscore, and lowercase 't'

If it works, go to step 2. If it fails with "No module named _tkinter", your Python configuration needs to be modified to include this module (which is an extension module implemented in C).如果成功,请转到第 2 步。如果失败并显示“No module named _tkinter”,则需要修改 Python 配置以包含此模块(它是用 C 实现的扩展模块)。 Do not edit Modules/Setup (it is out of date).不要编辑模块/设置(这是过时的)。 You may have to install Tcl and Tk (when using RPM, install the -devel RPMs as well) and/or edit the setup.py script to point to the right locations where Tcl/Tk is installed.您可能必须安装 Tcl 和 Tk(使用 RPM 时,也安装 -devel RPM)和/或编辑 setup.py 脚本以指向安装 Tcl/Tk 的正确位置。 If you install Tcl/Tk in the default locations, simply rerunning "make" should build the _tkinter extension.如果您在默认位置安装 Tcl/Tk,只需重新运行“make”即可构建 _tkinter 扩展。 If it fails with an error from the dynamic linker, see above (for Unix, check for a header/library file mismatch; for Windows, check that the TCL/TK DLLs can be found).如果它因动态链接器的错误而失败,请参见上文(对于 Unix,检查头文件/库文件是否不匹配;对于 Windows,检查是否可以找到 TCL/TK DLL)。

Step 2 - can Tkinter be imported?第 2 步 - 可以导入 Tkinter 吗?

Try the correct command for your version at the Python prompt:在 Python 提示符下为您的版本尝试正确的命令:

import Tkinter # no underscore, uppercase 'T' for versions prior to V3.0

import tkinter # no underscore, lowercase 't' for V3.0 and later

If it works, go to step 3. If it fails with "No module named Tkinter", your Python configuration need to be changed to include the directory that contains Tkinter.py in its default module search path.如果成功,请转到第 3 步。如果失败并显示“No module named Tkinter”,则需要更改 Python 配置以在其默认模块搜索路径中包含包含 Tkinter.py 的目录。 You have probably forgotten to define TKPATH in the Modules/Setup file.您可能忘记在 Modules/Setup 文件中定义 TKPATH。 A temporary workaround would be to find that directory and add it to your PYTHONPATH environment variable.临时解决方法是找到该目录并将其添加到您的 PYTHONPATH 环境变量中。 It is the subdirectory named "lib-tk" of the Python library directory (when using Python 1.4 or before, it is named "tkinter").它是 Python 库目录下名为“lib-tk”的子目录(使用 Python 1.4 或更早版本时,它被命名为“tkinter”)。

Source https://wiki.python.org/moin/TkInter来源https://wiki.python.org/moin/TkInter

您不能在 termux 上安装 tkinter 或任何图形库或框架,因为 termux 没有 GUI 和相关的图形标题。

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

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