I deinstalled tk and changed my code to your suggestion, but there is still the same error. If i run:
$ pip3 show tkinter
then there is the output:
WARNING: Package(s) not found: tkinter
Looking at it calmly, @dmt is right, the libtk8.6.so library that comes with the tk package is missing. You can check if it is in your system with this command:
ls /usr/lib/libtk8.6.so
That library comes with the manjaro tk package. You can install it with:
pacman -S tk
The tk package is missing. But if I try:
pacman -S tk
there is an error:
resolving dependencies...
looking for conflicting packages...
Packages (1) tk-8.6.13-1
Total Download Size: 1.90 MiB
Total Installed Size: 4.84 MiB
:: Proceed with installation? [Y/n] y
:: Retrieving packages...
tk-8.6.13-1-x86_64 1942.1 KiB 870 KiB/s 00:02 [######################] 100%
(1/1) checking keys in keyring [######################] 100%
(1/1) checking package integrity [######################] 100%
error: tk: signature from "Antonio Rojas <arojas@archlinux.org>" is unknown trust
:: File /var/cache/pacman/pkg/tk-8.6.13-1-x86_64.pkg.tar.zst is corrupted (invalid or corrupted package (PGP signature)).
Do you want to delete it? [Y/n] y
error: failed to commit transaction (invalid or corrupted package (PGP signature))
Errors occurred, no packages were upgraded.
Bad signature, refresh keyring with:
sudo pacman -Sy archlinux-keyring manjaro-keyring
If you have more trouble with Keys:
Thank you!
Now the output is:
warning: tk-8.6.13-1 is up to date -- reinstalling
resolving dependencies...
looking for conflicting packages...
Packages (1) tk-8.6.13-1
Total Installed Size: 4.84 MiB
Net Upgrade Size: 0.00 MiB
:: Proceed with installation? [Y/n] y
(1/1) checking keys in keyring [######################] 100%
(1/1) checking package integrity [######################] 100%
(1/1) loading package files [######################] 100%
(1/1) checking for file conflicts [######################] 100%
(1/1) checking available disk space [######################] 100%
:: Processing package changes...
(1/1) reinstalling tk [######################] 100%
:: Running post-transaction hooks...
(1/1) Arming ConditionNeedsUpdate...
but die error still exists. If I try to run the programm in vscode der is still:
bin/python /home/(my username)/Dokumente/Programmieren/Python/SpielTkinter.py
Traceback (most recent call last):
File "/home/(my username)/Dokumente/Programmieren/Python/SpielTkinter.py", line 1, in <module>
from tkinter import *
ModuleNotFoundError: No module named 'tkinter'
Does it work in a terminal?
vscode will need to be configured, not sure I can help with that as I donât use it.
It seems to be using a different python interpreter, one that doesnât come with tkinter.
https://stackoverflow.com/questions/69603788/how-to-pip-install-tkinter - spoiler: you canât
TL;DR Change the python interpreter that vscode uses.
preferably donât use VSCode. Use IDLE or Spyder or PyCharm.or KDE Develop or something else.
Where are you using pip install ⌠? It is preferable that you use pip install ⌠in a Python virtual Environment. But if you have set up the pyvenv then tkinter will be included in the venv.
https://www.pragmaticlinux.com/2021/12/create-a-python-virtual-environment-in-the-linux-terminal/
Now it works in Console. I try to do it with Visual STudio now, but if it doesnt work Iâm going to switch the IDE.
Thanks to you all for your help. I learnd much and the most important stuff works.
You probably set up a custom environment (willingly or not) where itâs using a different Python environment than your systemâs one.
Happy to see itâs solved, but credits for the solution must go to @dmt as he told us which was the real problem.
This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.