简体   繁体   中英

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.). All this modules - tkinter, that should be preinstalled, are not there - and it is not possible to install them. pip install tkinter ->Could not find a version that satisfies the requirement time (from versions: ) No matching distribution found for tkinter. if I try with: apt-get install python3-tk Still nothing - error placing file. apt-get update and apt upgrade didn't help...

To install tkinter in Termux just simply do:

pkg install python-tkinter

As mentioned here: https://github.com/termux/x11-packages/issues/172#issuecomment-554781785

Checking your Tkinter support

A good way to systematically check whether your Tkinter support is working is the following.

Enter an interactive Python interpreter in a shell on an X console.

Step 1 - can _tkinter be imported?

Try the following command at the Python prompt:

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). 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. If you install Tcl/Tk in the default locations, simply rerunning "make" should build the _tkinter extension. 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).

Step 2 - can Tkinter be imported?

Try the correct command for your version at the Python prompt:

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. You have probably forgotten to define TKPATH in the Modules/Setup file. A temporary workaround would be to find that directory and add it to your PYTHONPATH environment variable. It is the subdirectory named "lib-tk" of the Python library directory (when using Python 1.4 or before, it is named "tkinter").

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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