Python Forum
tkinter installation
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
tkinter installation
#1
Hi

I failed installing tkinter
python -m pip install tkinter
Defaulting to user installation because normal site-packages is not writeable
ERROR: Could not find a version that satisfies the requirement tkinter (from versions: none)
ERROR: No matching distribution found for tkinter
What shall I do ?

Arbiel
Reply
#2
I tried it too and got the same error message. Anyway, import tkinter is not a problem in the Python shell in my case. Have you already tried to import the module? It may be already installed.
Reply
#3
  • which OS do you use?
  • which Python version do you use?

is automatically installed with most python versions
try simple app:
import tkinter as tk

def simple_app(parent):
   parent.title("It's alive!")

if __name__ == '__main__':
    root = tk.Tk()
    simple_app(root)
    root.mainloop()
Reply
#4
Hi Larz60+

The OS is Ubuntu 16.04, and Python : 3.8.0 (I'll include this information into my signature)

Before asking for help, I tried
Error:
>>> import tkinter Traceback (most recent call last): File "<stdin>", line 1, in <module> ModuleNotFoundError: No module named 'tkinter' Error in sys.excepthook: Traceback (most recent call last): File "/usr/lib/python3/dist-packages/apport_python_hook.py", line 63, in apport_excepthook from apport.fileutils import likely_packaged, get_recent_crashes File "/usr/lib/python3/dist-packages/apport/__init__.py", line 5, in <module> from apport.report import Report File "/usr/lib/python3/dist-packages/apport/report.py", line 30, in <module> import apport.fileutils File "/usr/lib/python3/dist-packages/apport/fileutils.py", line 23, in <module> from apport.packaging_impl import impl as packaging File "/usr/lib/python3/dist-packages/apport/packaging_impl.py", line 24, in <module> import apt File "/usr/lib/python3/dist-packages/apt/__init__.py", line 23, in <module> import apt_pkg ModuleNotFoundError: No module named 'apt_pkg' Original exception was: Traceback (most recent call last): File "<stdin>", line 1, in <module> ModuleNotFoundError: No module named 'tkinter'
Arbiel
Reply
#5
tkinter is included with python 3.8.
make sure environment variables are set correctly, run:
python -V
do you see python 3.8?
Reply
#6
remi@remi-Vostro-3550:~$ python -V
Python 3.8.0
remi@remi-Vostro-3550:~$ python
Python 3.8.0 (default, Oct 28 2019, 16:14:01) 
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.path
['', '/usr/lib/python38.zip', '/usr/lib/python3.8', '/usr/lib/python3.8/lib-dynload', '/home/remi/.local/lib/python3.8/site-packages', '/usr/local/lib/python3.8/dist-packages', '/usr/lib/python3/dist-packages']
>>> exit()
remi@remi-Vostro-3550:~$ for rep in '/usr/lib/python38.zip' '/usr/lib/python3.8' '/usr/lib/python3.8/lib-dynload' '/home/remi/.local/lib/python3.8/site-packages' '/usr/local/lib/python3.8/dist-packages' '/usr/lib/python3/dist-packages'; do  echo "${rep}"; ls -1 "${rep}" | grep tk; done
/usr/lib/python38.zip
ls: impossible d'accéder à '/usr/lib/python38.zip': Aucun fichier ou dossier de ce type
/usr/lib/python3.8
/usr/lib/python3.8/lib-dynload
/home/remi/.local/lib/python3.8/site-packages
/usr/local/lib/python3.8/dist-packages
/usr/lib/python3/dist-packages
pygtkcompat
remi@remi-Vostro-3550:~$ 
So, should I reinstall Python ?

Arbiel
Reply
#7
reinstall seems like a viable option.
follow snippsat's guide here: https://python-forum.io/Thread-Part-1-Li...nvironment
Reply
#8
Hi Larz60+

Reinstalling Python was not exactly the best option. In fact, on Unix-like systems, tkinter is not included in Python, but through Python's extensions. I got aware of this after having reinstalled Python-3.8.2, and failed.

The way to go is explained the Python Developer's Guide.
Reply
#9
glad to hear all is well.
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020