Does the Python Tkinter library still exist?

Asked

Viewed 285 times

3

I use Ubuntu and as this library does not come installed by default on linux, I was trying to install it via Pip but I can not find it on the official Python site.

  • According to the documentation [https://docs.python.org/3/library/tkinter.html]: "Both Tk and Tkinter are available on Most Unix Platforms, as well as on Windows systems. (Tk itself is not part of Python; it is maintained at Activestate.)"

1 answer

4


It depends on the version of Python or Ubuntu you are running, among other things, but yes, Tkinter still exists.

If you are using Python 3:

sudo apt-get update
sudo apt-get install python3-tk

If you’re running the Python 2

sudo apt-get update
sudo apt-get install python-tk

Installing the latest stable version directly (I had compatibility issues with some libraries in version 3.7):

sudo apt-get install python3.6-tk

Depending on your version of Ubuntu the process may be a little different. I saw a user with the version 16.04 that needed to do the following:

$ sudo apt-get install python-tk python3-tk tk-dev
$ pyenv install 3.6.2

If none of this works, you may need to add a repository:

sudo add-apt-repository main
sudo apt-get install python3-tk

P.S. 1 - Recalling that the Pyenv is a version management tool that can be installed through from this repository on Github.

P.S. 2 - Tkinter import in Python 2 is different from import in Python 3.

#Python 3
import tkinter

#Python 2
import Tkinter
  • "3.6" is an old Python already - the last stable is 3.7

  • Yeah, but like I said, I had a problem with 3.7 a few months ago, and I had to downgrade. Then I was afraid to make a new upgrade to see if it is already solved haha

Browser other questions tagged

You are not signed in. Login or sign up in order to post.