I am trying to use tkinter for my Python Code. I installed it per pacman and trough pip. but there is an error that no moudel is named tkinter. I am using Visual Studio Code.
Without any error message, there is nothing to go on.
Installing with pip and pamac will lead to errors anyway.
There is an eeror message in VSCode: ModuleNotFoundError: No module named ātkinterā
And I first installed it with pacman and than tried pip.
Does it work on the terminal?
Which package did you install exactly?
If I try in Console:
Traceback (most recent call last):
File ā/home/(myusername)/Dokumente/Programmieren/Python/SpielTkinter.pyā, line 1, in
import tkinter as tk
File ā/usr/lib/python3.10/tkinter/init.pyā, line 37, in
import _tkinter # If this fails your Python may not be configured for Tk
ImportError: libtk8.6.so: cannot open shared object file: No such file or directory
Try:
$ pip3 show tkinter
To see if tkinter is installed. If so, remove this line in your code:
import tkinter as tk
And add this two lines:
from tkinter import *
from tkinter.ttk import *
Answer this please.
What command did you use?
Is your system up-to-date?
tkinter is part of the python package, you donāt need to install anything
sudo pacman -Fy /usr/lib/python3.10/tkinter/__init__.py
# should return this
usr/lib/python3.10/tkinter/__init__.py is owned by core/python 3.10.9-1
/usr/lib/libtk8.6.so
is owned by tk
, so either itās not installed, itās an earlier version, or itās been deleted somehow.
pacman -Qs tk
Try this:
sudo pacman -Syu tk python
Why? The usually recommended way is to not import using *
. I have no experience with tkinter, but import tkinter as tk
works for me (in idle).
The error seems to be coming from tkinter itself, not OPās code. Probably a partial update, or tk
not being installed. Whatever they installed might also cause problems.
I used: pip install tk
my system is up to date
And I used import tkinter as tk
I meant the pacman command too.
Please give the output of:
Fehler: GPGME-Fehler: Keine Daten
Fehler: GPGME-Fehler: Keine Daten
Fehler: GPGME-Fehler: Keine Daten
Fehler: GPGME-Fehler: Keine Daten
:: Paketdatenbanken werden synchronisiert ā¦
core 1597,9 KiB 4,51 MiB/s 00:00 [######################] 100%
extra 9,6 MiB 12,0 MiB/s 00:01 [######################] 100%
community 34,8 MiB 12,2 MiB/s 00:03 [######################] 100%
multilib 253,9 KiB 5,39 MiB/s 00:00 [######################] 100%
Fehler: GPGME-Fehler: Keine Daten
Fehler: GPGME-Fehler: Keine Daten
Fehler: GPGME-Fehler: Keine Daten
Fehler: GPGME-Fehler: Keine Daten
Fehler: Keine Datenbank konnte synchronisiert werden (Ungültige oder beschädigte Datenbank (PGP-Signatur))
Sorry my system is in German. Fehler means Error
Moderator edit: In the future, please use proper formatting: [HowTo] Post command output and file content as formatted text
I ran the Skript but nothing changed. Itās still the same error.
Stop mixing local and system Python packages.
Please see:
Iāll do! Thank You!
Now this is the output of sudo pacman -Fy /usr/lib/python3.10/tkinter/init.py:
core 1597,9 KiB 1216 KiB/s 00:01 [######################] 100%
extra 9,6 MiB 644 KiB/s 00:15 [######################] 100%
community 34,8 MiB 865 KiB/s 00:41 [######################] 100%
multilib 253,9 KiB 897 KiB/s 00:00 [######################] 100%
usr/lib/python3.10/tkinter/__init__.py ist in core/python 3.10.9-1 enthalten
But it still dont works.
Now itās your turn. Please edit your post accordingly.
Sorry. Iām very new but know it shpuld be fine.
tk 0.1.0 Jul 8, 2019
TensorKit is a deep learning helper between Python and C++.
tkinter is a core python module, you donāt have to install it.
That should be satisfied by the package extra/tk.
Well, itās an easy way to directly load tkinter. If it works and import tkinter as tk
does not, you may have something already defined as tk. Thatās what seems to happen, the op has tensorkit package as tk.

I used: pip install tk
my system is up to date
And I used import tkinter as tk
You are installing tk package, tk is tensorkit, not tkinter. Then you try to load tkinter also as tk, may be thereās a name conflict between both.
Uninstall tk package if you donāt need it and the problem importing tkinter may be solved.

If it works and
import tkinter as tk
does not, you may have something already defined as tk. Thatās what seems to happen, the op has tensorkit package as tk.
I see you donāt like to read tracebacks.
They installed tensorkit, which makes it available to import, presumably like so: import tk
or import tk as tensorkit
.
However they imported tkinter
, which in turn imported _tkinter
which complained that libtk8.6.so
is missing.
libtk8.6.so
is owned by the tk
package in the repos (not to be confused with tensorkit), so either OP has an old version, itās not installed, or something weird is going on.