ΠΊΠ°ΠΊ ΡƒΡΡ‚Π°Π½ΠΎΠ²ΠΈΡ‚ΡŒ tkinter python windows

Как pip ΠΈΠ»ΠΈ Π»Π΅Π³ΠΊΠΎ ΡƒΡΡ‚Π°Π½ΠΎΠ²ΠΈΡ‚ΡŒ tkinter

ΠΌΠΎΠΉ холостой бросаСт ошибки, ΠΊΠΎΡ‚ΠΎΡ€Ρ‹Π΅ ΠΈ Π³ΠΎΠ²ΠΎΡ€ΠΈΡ‚ tkinter Π½Π΅Π²ΠΎΠ·ΠΌΠΎΠΆΠ½ΠΎ ΠΈΠΌΠΏΠΎΡ€Ρ‚ΠΈΡ€ΠΎΠ²Π°Ρ‚ΡŒ.

Ρ‚Π°ΠΌ, каТСтся, ΠΌΠ½ΠΎΠ³ΠΎ ΠΈΠΌΠ΅Π½ ΠΏΠ°ΠΊΠ΅Ρ‚ΠΎΠ² Π»Π΅Ρ‚Π°Ρ‚ΡŒ Π²ΠΎΠΊΡ€ΡƒΠ³ для этого.

это ΠΈ Π΄Ρ€ΡƒΠ³ΠΈΠ΅ Ρ€Π°Π·Π»ΠΈΡ‡Π½Ρ‹Π΅ Π²Π°Ρ€ΠΈΠ°Π½Ρ‚Ρ‹ с tkinter-pypy Π½Π΅ Ρ€Π°Π±ΠΎΡ‚Π°ΡŽΡ‚.

10 ΠΎΡ‚Π²Π΅Ρ‚ΠΎΠ²

Ну я Π²ΠΈΠΆΡƒ здСсь Π΄Π²Π° Ρ€Π΅ΡˆΠ΅Π½ΠΈΡ:

Tkinter (ΠΈ, начиная с Python 3.1, ttk) Π²ΠΊΠ»ΡŽΡ‡Π΅Π½Ρ‹ Π²ΠΎ всС стандартныС дистрибутивы Python. Π’Π°ΠΆΠ½ΠΎ, Ρ‡Ρ‚ΠΎΠ±Ρ‹ Π²Ρ‹ использовали Π²Π΅Ρ€ΡΠΈΡŽ Python, ΠΏΠΎΠ΄Π΄Π΅Ρ€ΠΆΠΈΠ²Π°ΡŽΡ‰ΡƒΡŽ Tk 8.5 ΠΈΠ»ΠΈ Π²Ρ‹ΡˆΠ΅, ΠΈ ttk. ΠœΡ‹ Ρ€Π΅ΠΊΠΎΠΌΠ΅Π½Π΄ΡƒΠ΅ΠΌ ΡƒΡΡ‚Π°Π½ΠΎΠ²ΠΈΡ‚ΡŒ дистрибутив «ActivePython» ΠΈΠ· ActiveState, ΠΊΠΎΡ‚ΠΎΡ€Ρ‹ΠΉ Π²ΠΊΠ»ΡŽΡ‡Π°Π΅Ρ‚ Π² сСбя всС, Ρ‡Ρ‚ΠΎ Π²Ρ‹ Π½Π΅ΠΎΠ±Ρ…ΠΎΠ΄ΠΈΠΌΠΎΡΡ‚ΡŒ.

Π² вашСм Π²Π΅Π±-Π±Ρ€Π°ΡƒΠ·Π΅Ρ€Π΅ ΠΏΠ΅Ρ€Π΅ΠΉΠ΄ΠΈΡ‚Π΅ Π²Activestate.com, ΠΈ слСдуйтС ΠΏΠΎ ссылкам, Ρ‡Ρ‚ΠΎΠ±Ρ‹ Π·Π°Π³Ρ€ΡƒΠ·ΠΈΡ‚ΡŒ ΠΈΠ·Π΄Π°Π½ΠΈΠ΅ сообщСства ActivePython для Windows. Π£Π±Π΅Π΄ΠΈΡ‚Π΅ΡΡŒ, Ρ‡Ρ‚ΠΎ Π²Ρ‹ Π·Π°Π³Ρ€ΡƒΠΆΠ°Π΅Ρ‚Π΅ 3.1 ΠΈΠ»ΠΈ Π±ΠΎΠ»Π΅Π΅ Π½ΠΎΠ²ΡƒΡŽ Π²Π΅Ρ€ΡΠΈΡŽ, Π° Π½Π΅ 2.X вСрсии.

Π­Ρ‚ΠΎ Π΄ΠΎΠ»ΠΆΠ½ΠΎ Π΄Π°Ρ‚ΡŒ Π²Π°ΠΌ ΠΊΠΎΠΌΠ°Π½Π΄Π½ΡƒΡŽ строку Python. Π’ ΠΊΠΎΠΌΠ°Π½Π΄Π½ΠΎΠΉ строкС Π²Π²Π΅Π΄ΠΈΡ‚Π΅ ΡΠ»Π΅Π΄ΡƒΡŽΡ‰ΠΈΠ΅ Π΄Π²Π΅ ΠΊΠΎΠΌΠ°Π½Π΄Ρ‹:

Π­Ρ‚ΠΎ Π΄ΠΎΠ»ΠΆΠ½ΠΎ ΠΏΠΎΡΠ²ΠΈΡ‚ΡŒΡΡ нСбольшоС ΠΎΠΊΠ½ΠΎ; пСрвая строка Π² Π²Π΅Ρ€Ρ…Π½Π΅ΠΉ части ΠΎΠΊΠ½Π° Π΄ΠΎΠ»ΠΆΠ½Π° ΡΠΊΠ°Π·Π°Ρ‚ΡŒ: «ΡΡ‚ΠΎ Tcl / Tk вСрсии 8.5»; ΡƒΠ±Π΅Π΄ΠΈΡ‚Π΅ΡΡŒ, Ρ‡Ρ‚ΠΎ это Π½Π΅ 8.4!

2) Π£Π΄Π°Π»ΠΈΡ‚Π΅ 64-Π±ΠΈΡ‚Π½Ρ‹ΠΉ Python ΠΈ установитС 32-Π±ΠΈΡ‚Π½Ρ‹ΠΉ Python.

Π±ΠΈΠ±Π»ΠΈΠΎΡ‚Π΅ΠΊΠ° Tkinter встроСна Π² ΠΊΠ°ΠΆΠ΄ΡƒΡŽ установку Python. И ΠΏΠΎΡΠΊΠΎΠ»ΡŒΠΊΡƒ Π²Ρ‹ Π½Π°Ρ…ΠΎΠ΄ΠΈΡ‚Π΅ΡΡŒ Π² windows, я ΡΡ‡ΠΈΡ‚Π°ΡŽ, Ρ‡Ρ‚ΠΎ Π²Ρ‹ установили python Ρ‡Π΅Ρ€Π΅Π· Π΄Π²ΠΎΠΈΡ‡Π½Ρ‹Π΅ Ρ„Π°ΠΉΠ»Ρ‹ Π½Π° своСм Π²Π΅Π±-сайтС?

Ссли Π΄Π°, Ρ‚ΠΎ, скорСС всСго, Π²Ρ‹ Π²Π²ΠΎΠ΄ΠΈΡ‚Π΅ ΠΊΠΎΠΌΠ°Π½Π΄Ρƒ Π½Π΅ΠΏΡ€Π°Π²ΠΈΠ»ΡŒΠ½ΠΎ. Π”ΠΎΠ»ΠΆΠ½ΠΎ Π±Ρ‹Ρ‚ΡŒ:

import Tkinter as tk

ΠΎΠ±Ρ€Π°Ρ‚ΠΈΡ‚Π΅ Π²Π½ΠΈΠΌΠ°Π½ΠΈΠ΅ Π½Π° Π·Π°Π³Π»Π°Π²Π½ΡƒΡŽ T Π² Π½Π°Ρ‡Π°Π»Π΅ Tkinter.

import tkinter as tk

Если Π²Ρ‹ ΠΈΡΠΏΠΎΠ»ΡŒΠ·ΡƒΠ΅Ρ‚Π΅ virtualenv, ΠΌΠΎΠΆΠ½ΠΎ ΡƒΡΡ‚Π°Π½ΠΎΠ²ΠΈΡ‚ΡŒ tkinter с ΠΏΠΎΠΌΠΎΡ‰ΡŒΡŽ sudo apt-get install python-tk (вмСсто python2), sudo apt-get install python3-tk (python3), ΠΈ ΠΎΠ½ Π±ΡƒΠ΄Π΅Ρ‚ ΠΎΡ‚Π»ΠΈΡ‡Π½ΠΎ Ρ€Π°Π±ΠΎΡ‚Π°Ρ‚ΡŒ Π² Π²ΠΈΡ€Ρ‚ΡƒΠ°Π»ΡŒΠ½ΠΎΠΉ срСдС

ΠΏΡ€ΠΈ установкС python для Windows ΠΈΡΠΏΠΎΠ»ΡŒΠ·ΡƒΠΉΡ‚Π΅ ΡΡ‚Π°Π½Π΄Π°Ρ€Ρ‚Π½ΡƒΡŽ ΠΎΠΏΡ†ΠΈΡŽ ΠΈΠ»ΠΈ установитС всС, Ρ‡Ρ‚ΠΎ ΠΎΠ½Π° просит. Π― ΠΏΠΎΠ»ΡƒΡ‡ΠΈΠ» ΠΎΡˆΠΈΠ±ΠΊΡƒ, ΠΏΠΎΡ‚ΠΎΠΌΡƒ Ρ‡Ρ‚ΠΎ я снял Π²Ρ‹Π±ΠΎΡ€ tcl.

ΠΊΠ°ΠΊ ΡƒΡΡ‚Π°Π½ΠΎΠ²ΠΈΡ‚ΡŒ tkinter python windows. 5d484d7d711d81c0096cfe68f14c453f. ΠΊΠ°ΠΊ ΡƒΡΡ‚Π°Π½ΠΎΠ²ΠΈΡ‚ΡŒ tkinter python windows Ρ„ΠΎΡ‚ΠΎ. ΠΊΠ°ΠΊ ΡƒΡΡ‚Π°Π½ΠΎΠ²ΠΈΡ‚ΡŒ tkinter python windows-5d484d7d711d81c0096cfe68f14c453f. ΠΊΠ°Ρ€Ρ‚ΠΈΠ½ΠΊΠ° ΠΊΠ°ΠΊ ΡƒΡΡ‚Π°Π½ΠΎΠ²ΠΈΡ‚ΡŒ tkinter python windows. ΠΊΠ°Ρ€Ρ‚ΠΈΠ½ΠΊΠ° 5d484d7d711d81c0096cfe68f14c453f. ΠΌΠΎΠΉ холостой бросаСт ошибки, ΠΊΠΎΡ‚ΠΎΡ€Ρ‹Π΅ ΠΈ Π³ΠΎΠ²ΠΎΡ€ΠΈΡ‚ tkinter Π½Π΅Π²ΠΎΠ·ΠΌΠΎΠΆΠ½ΠΎ ΠΈΠΌΠΏΠΎΡ€Ρ‚ΠΈΡ€ΠΎΠ²Π°Ρ‚ΡŒ.

Ρ‚ΠΎ ΠΆΠ΅ самоС касаСтся Python 3:

ΠΊΠ°ΠΊ ΡƒΡΡ‚Π°Π½ΠΎΠ²ΠΈΡ‚ΡŒ tkinter python windows. 2b9f3e22b19c962d340a2ccacdb6bce0. ΠΊΠ°ΠΊ ΡƒΡΡ‚Π°Π½ΠΎΠ²ΠΈΡ‚ΡŒ tkinter python windows Ρ„ΠΎΡ‚ΠΎ. ΠΊΠ°ΠΊ ΡƒΡΡ‚Π°Π½ΠΎΠ²ΠΈΡ‚ΡŒ tkinter python windows-2b9f3e22b19c962d340a2ccacdb6bce0. ΠΊΠ°Ρ€Ρ‚ΠΈΠ½ΠΊΠ° ΠΊΠ°ΠΊ ΡƒΡΡ‚Π°Π½ΠΎΠ²ΠΈΡ‚ΡŒ tkinter python windows. ΠΊΠ°Ρ€Ρ‚ΠΈΠ½ΠΊΠ° 2b9f3e22b19c962d340a2ccacdb6bce0. ΠΌΠΎΠΉ холостой бросаСт ошибки, ΠΊΠΎΡ‚ΠΎΡ€Ρ‹Π΅ ΠΈ Π³ΠΎΠ²ΠΎΡ€ΠΈΡ‚ tkinter Π½Π΅Π²ΠΎΠ·ΠΌΠΎΠΆΠ½ΠΎ ΠΈΠΌΠΏΠΎΡ€Ρ‚ΠΈΡ€ΠΎΠ²Π°Ρ‚ΡŒ.

Π― Ρ€Π΅ΡˆΠΈΠ» Ρ‚Ρƒ ΠΆΠ΅ ΠΏΡ€ΠΎΠ±Π»Π΅ΠΌΡƒ, ΠΈΡΠΏΠΎΠ»ΡŒΠ·ΡƒΡ эти Π΄Π²Π΅ ΠΊΠΎΠΌΠ°Π½Π΄Ρ‹ 100%

Π― ΠΏΡƒΠ±Π»ΠΈΠΊΡƒΡŽ Π² качСствС Π²Π΅Ρ€Ρ…Π½Π΅Π³ΠΎ ΠΎΡ‚Π²Π΅Ρ‚Π° requotes Π΄ΠΎΠΊΡƒΠΌΠ΅Π½Ρ‚Π°Ρ†ΠΈΡŽ, ΠΊΠΎΡ‚ΠΎΡ€ΡƒΡŽ я Π½Π΅ нашСл ΠΏΠΎΠ»Π΅Π·Π½ΠΎΠΉ.

tkinter поставляСтся Π² ΠΊΠΎΠΌΠΏΠ»Π΅ΠΊΡ‚Π΅ с python install Π½Π° windows, Если Π²Ρ‹ Π²Ρ‹Π±Π΅Ρ€Π΅Ρ‚Π΅ Π΅Π³ΠΎ Π²ΠΎ врСмя ΠΎΠΊΠ½Π° установки.

Ρ€Π΅ΡˆΠ΅Π½ΠΈΠ΅ состоит Π² Ρ‚ΠΎΠΌ, Ρ‡Ρ‚ΠΎΠ±Ρ‹ Π²ΠΎΡΡΡ‚Π°Π½ΠΎΠ²ΠΈΡ‚ΡŒ установку (Ρ‡Π΅Ρ€Π΅Π· ΡƒΠ΄Π°Π»Π΅Π½ΠΈΠ΅ GUI Π² порядкС) ΠΈ Π²Ρ‹Π±Ρ€Π°Ρ‚ΡŒ для установки tk Π½Π° этот Ρ€Π°Π·. Π’ этом процСссС ΠΌΠΎΠΆΠ΅Ρ‚ ΠΏΠΎΡ‚Ρ€Π΅Π±ΠΎΠ²Π°Ρ‚ΡŒΡΡ ΡƒΠΊΠ°Π·Π°Ρ‚ΡŒ ΠΈΠ»ΠΈ ΠΏΠΎΠ²Ρ‚ΠΎΡ€Π½ΠΎ Π·Π°Π³Ρ€ΡƒΠ·ΠΈΡ‚ΡŒ Π΄Π²ΠΎΠΈΡ‡Π½Ρ‹ΠΉ Ρ„Π°ΠΉΠ». Π—Π°Π³Ρ€ΡƒΠ·ΠΊΠ° нСпосрСдствСнно ΠΈΠ· activestate Π½Π΅ Ρ€Π°Π±ΠΎΡ‚Π°Π»Π° для мСня.

Π­Ρ‚ΠΎ обычная ΠΏΡ€ΠΎΠ±Π»Π΅ΠΌΠ° люди ΠΈΠΌΠ΅ΡŽΡ‚ Π½Π° windows, ΠΊΠ°ΠΊ это Π»Π΅Π³ΠΊΠΎ Π½Π΅ хотят ΡƒΡΡ‚Π°Π½Π°Π²Π»ΠΈΠ²Π°Ρ‚ΡŒ TCL / TK, Ссли Π²Ρ‹ Π½Π΅ Π·Π½Π°Π΅Ρ‚Π΅, Ρ‡Ρ‚ΠΎ это Ρ‚Π°ΠΊΠΎΠ΅, Π½ΠΎ Matplotlib ΠΈ Ρ‚.Π΄. Ρ‚Ρ€Π΅Π±ΡƒΡŽΡ‚ этого.

Π˜ΡΡ‚ΠΎΡ‡Π½ΠΈΠΊ

How to pip or easy_install tkinter on Windows

My Idle is throwing errors that and says tkinter can’t be imported.

There seem to be a lot of package names flying around for this.

This and other assorted variations with tkinter-pypy aren’t working.

I’m on Windows with Python 2.7 and I don’t have apt-get or other system package managers.

ΠΊΠ°ΠΊ ΡƒΡΡ‚Π°Π½ΠΎΠ²ΠΈΡ‚ΡŒ tkinter python windows. zgIdn. ΠΊΠ°ΠΊ ΡƒΡΡ‚Π°Π½ΠΎΠ²ΠΈΡ‚ΡŒ tkinter python windows Ρ„ΠΎΡ‚ΠΎ. ΠΊΠ°ΠΊ ΡƒΡΡ‚Π°Π½ΠΎΠ²ΠΈΡ‚ΡŒ tkinter python windows-zgIdn. ΠΊΠ°Ρ€Ρ‚ΠΈΠ½ΠΊΠ° ΠΊΠ°ΠΊ ΡƒΡΡ‚Π°Π½ΠΎΠ²ΠΈΡ‚ΡŒ tkinter python windows. ΠΊΠ°Ρ€Ρ‚ΠΈΠ½ΠΊΠ° zgIdn. ΠΌΠΎΠΉ холостой бросаСт ошибки, ΠΊΠΎΡ‚ΠΎΡ€Ρ‹Π΅ ΠΈ Π³ΠΎΠ²ΠΎΡ€ΠΈΡ‚ tkinter Π½Π΅Π²ΠΎΠ·ΠΌΠΎΠΆΠ½ΠΎ ΠΈΠΌΠΏΠΎΡ€Ρ‚ΠΈΡ€ΠΎΠ²Π°Ρ‚ΡŒ.

ΠΊΠ°ΠΊ ΡƒΡΡ‚Π°Π½ΠΎΠ²ΠΈΡ‚ΡŒ tkinter python windows. OZlRo. ΠΊΠ°ΠΊ ΡƒΡΡ‚Π°Π½ΠΎΠ²ΠΈΡ‚ΡŒ tkinter python windows Ρ„ΠΎΡ‚ΠΎ. ΠΊΠ°ΠΊ ΡƒΡΡ‚Π°Π½ΠΎΠ²ΠΈΡ‚ΡŒ tkinter python windows-OZlRo. ΠΊΠ°Ρ€Ρ‚ΠΈΠ½ΠΊΠ° ΠΊΠ°ΠΊ ΡƒΡΡ‚Π°Π½ΠΎΠ²ΠΈΡ‚ΡŒ tkinter python windows. ΠΊΠ°Ρ€Ρ‚ΠΈΠ½ΠΊΠ° OZlRo. ΠΌΠΎΠΉ холостой бросаСт ошибки, ΠΊΠΎΡ‚ΠΎΡ€Ρ‹Π΅ ΠΈ Π³ΠΎΠ²ΠΎΡ€ΠΈΡ‚ tkinter Π½Π΅Π²ΠΎΠ·ΠΌΠΎΠΆΠ½ΠΎ ΠΈΠΌΠΏΠΎΡ€Ρ‚ΠΈΡ€ΠΎΠ²Π°Ρ‚ΡŒ.

14 Answers 14

The Tkinter library is built-in with every Python installation. And since you are on Windows, I believe you installed Python through the binaries on their website?

If so, Then most probably you are typing the command wrong. It should be:

Note the capital T at the beginning of Tkinter.

ΠΊΠ°ΠΊ ΡƒΡΡ‚Π°Π½ΠΎΠ²ΠΈΡ‚ΡŒ tkinter python windows. eYXpE. ΠΊΠ°ΠΊ ΡƒΡΡ‚Π°Π½ΠΎΠ²ΠΈΡ‚ΡŒ tkinter python windows Ρ„ΠΎΡ‚ΠΎ. ΠΊΠ°ΠΊ ΡƒΡΡ‚Π°Π½ΠΎΠ²ΠΈΡ‚ΡŒ tkinter python windows-eYXpE. ΠΊΠ°Ρ€Ρ‚ΠΈΠ½ΠΊΠ° ΠΊΠ°ΠΊ ΡƒΡΡ‚Π°Π½ΠΎΠ²ΠΈΡ‚ΡŒ tkinter python windows. ΠΊΠ°Ρ€Ρ‚ΠΈΠ½ΠΊΠ° eYXpE. ΠΌΠΎΠΉ холостой бросаСт ошибки, ΠΊΠΎΡ‚ΠΎΡ€Ρ‹Π΅ ΠΈ Π³ΠΎΠ²ΠΎΡ€ΠΈΡ‚ tkinter Π½Π΅Π²ΠΎΠ·ΠΌΠΎΠΆΠ½ΠΎ ΠΈΠΌΠΏΠΎΡ€Ρ‚ΠΈΡ€ΠΎΠ²Π°Ρ‚ΡŒ.

ΠΊΠ°ΠΊ ΡƒΡΡ‚Π°Π½ΠΎΠ²ΠΈΡ‚ΡŒ tkinter python windows. . ΠΊΠ°ΠΊ ΡƒΡΡ‚Π°Π½ΠΎΠ²ΠΈΡ‚ΡŒ tkinter python windows Ρ„ΠΎΡ‚ΠΎ. ΠΊΠ°ΠΊ ΡƒΡΡ‚Π°Π½ΠΎΠ²ΠΈΡ‚ΡŒ tkinter python windows-. ΠΊΠ°Ρ€Ρ‚ΠΈΠ½ΠΊΠ° ΠΊΠ°ΠΊ ΡƒΡΡ‚Π°Π½ΠΎΠ²ΠΈΡ‚ΡŒ tkinter python windows. ΠΊΠ°Ρ€Ρ‚ΠΈΠ½ΠΊΠ° . ΠΌΠΎΠΉ холостой бросаСт ошибки, ΠΊΠΎΡ‚ΠΎΡ€Ρ‹Π΅ ΠΈ Π³ΠΎΠ²ΠΎΡ€ΠΈΡ‚ tkinter Π½Π΅Π²ΠΎΠ·ΠΌΠΎΠΆΠ½ΠΎ ΠΈΠΌΠΏΠΎΡ€Ρ‚ΠΈΡ€ΠΎΠ²Π°Ρ‚ΡŒ.

If you are using virtualenv, it is fine to install tkinter using sudo apt-get install python-tk (python2), sudo apt-get install python3-tk (python3), and and it will work fine in the virtual environment

Well I can see two solutions here:

Tkinter (and, since Python 3.1, ttk) are included with all standard Python distributions. It is important that you use a version of Python supporting Tk 8.5 or greater, and ttk. We recommend installing the «ActivePython» distribution from ActiveState, which includes everything you’ll need.

In your web browser, go to Activestate.com, and follow along the links to download the Community Edition of ActivePython for Windows. Make sure you’re downloading a 3.1 or newer version, not a 2.x version.

This should give you the Python command prompt. From the prompt, enter these two commands:

This should pop up a small window; the first line at the top of the window should say «This is Tcl/Tk version 8.5»; make sure it is not 8.4!

2) Uninstall 64-bit Python and install 32 bit Python.

Π˜ΡΡ‚ΠΎΡ‡Π½ΠΈΠΊ

Installing Tk

In this chapter, you’ll get Tk installed on your machine, verify it works, and then see a quick example of what a Tk program looks like.

Jump to Tk Install Instructions:

Though pretty much all macOS and Linux machines come with Tk installed already, it’s often an older version (typically 8.4.x or an early 8.5). You want to make sure you’ve got at least version 8.5 (preferably 8.6) to use the new widget set, so if that’s not already there, you’ll want to install the newer version.

You’ll need both Tk and bindings for the language you’re using it from. Sometimes these are bundled together, sometimes not. Though there are lots of ways to install Tk, often the easiest is to download and install one of the versions provided by ActiveState (www.activestate.com).

Users of recent Python versions can avoid this intermediate step. Starting with Python 3.7, the binary installers available at python.org now include everything you need to use Tk out of the box. If you’re using an earlier Python version, or want to compile it yourself, you’ll need to install Tcl/Tk on your system to do so. In this case, ActiveState’s distributions are still the recommended way to go.

Remember, this tutorial assumes you’re using Python 3, not Python 2. There are some significant differences between the two, including module naming, which is the first thing you’ll encounter when trying Tkinter.

ActiveState is a company that sells professional developer tools for dynamic languages. They also provide (for free) quality-controlled distributions of some of these languages, and happen to employ a number of core developers of these languages.

Installing Tk on macOS

Install Tk for Python (Tkinter) on macOS

The Easy Way

As noted, the easiest way to get Tk and Tkinter installed on your system is using Python’s binary installer, available at python.org. Thanks to work by Python core developer Ned Deily, binary installers starting with version 3.7 include Tcl and Tk.

Remember, we’re using Python 3.x here, not 2.x. As of this writing, the latest 3.9 installer (3.9.0rc1) includes Tk 8.6.8.

If, however, you’re compiling Python yourself, you’ll have more work to do. Read on.

Installing Tcl/Tk

The Tkinter module is included with core Python, of course, but you’ll need a version of Tcl/Tk on your system to compile it against. Do yourself a huge favor and get the most recent version.

Whatever you do, do not rely on the Tk versions included in macOS! Older versions included Tk 8.4.x. Even more recent macOS versions include an early 8.5 version (8.5.9, released in 2010), which has several serious bugs that are easily triggered by Tkinter.

While there are several different ways to get Tcl and Tk onto your machine, the easiest and most recommended is to use the ActiveTcl distribution.

In your web browser, visit www.activestate.com/products/activetcl. Download ActiveTcl (as of this writing, it’s version 8.6.9). Make sure to download an 8.6.x version, not something older! Note that you will need to create an account with ActiveState (no cost) to download it. After it’s downloaded, run the installer to get Tcl and Tk loaded onto your machine.

If you’re a masochist and want to read about other Tcl/Tk options and variations and how they interact with Python, see the Mac Tcl/Tk page at python.org If you want to compile Tcl/Tk from source, see www.tcl.tk.

Compiling Python

When compiling Python from source, you may need to tell it where to find the ActiveTcl (or other) distribution. Otherwise, it might not find any Tcl/Tk distribution (so Tkinter won’t work), or it could find the (ancient and broken) version of Tcl/Tk supplied with macOS.

The initial «%» is the Unix shell prompt; you don’t have to type it. The rest of it should all go on one line, without adding line breaks.

If you have multiple versions of Tcl/Tk installed on your system (and in the same frameworks), you may need to check inside the framework to ensure the most recent version is marked as the current one. If not, you may need to adjust your paths to point to the specific version (i.e., Versions/8.x/ ) within each framework.

When everything is built, be sure to test it out. Start Python from your terminal, e.g.

This should give you the Python command prompt. From the prompt, enter these two commands:

This should pop up a small window; the first line at the top of the window should say «This is Tcl/Tk version 8.6»; make sure it is not 8.4 or 8.5!

You can also get the exact version of Tcl/Tk that is being used with:

It should return something like ‘8.6.9’.

Verified install using ActiveTcl 8.6.9.8609.2 and Python 3.90rc1 source code from python.org on macOS 10.15.6.

Install Tk for Tcl on macOS

On macOS, the easiest way to get Tk is to install the «ActiveTcl» distribution from ActiveState, which includes Tcl, Tk, plus a number of other extension libraries.

In your web browser, go to www.activestate.com, and follow along the links to download the Community Edition of ActiveTcl. Note that you will need to create an account with ActiveState (no cost) to download it. Make sure you’re downloading an 8.6.x version, not an older version.

Run the installer to get everything loaded onto your machine. When you’re done, you’ll find a shiny new application called «Wish 8.6» inside the Utilities folder of your Applications folder. This is the «wish» shell, an application that includes both Tcl and Tk.

If you launch that application, you’ll see two windows popup (see below), one titled «Wish» which will contain your application, and the second titled «Console» which is where you can type in Tcl/Tk commands.

ΠΊΠ°ΠΊ ΡƒΡΡ‚Π°Π½ΠΎΠ²ΠΈΡ‚ΡŒ tkinter python windows. wish mac. ΠΊΠ°ΠΊ ΡƒΡΡ‚Π°Π½ΠΎΠ²ΠΈΡ‚ΡŒ tkinter python windows Ρ„ΠΎΡ‚ΠΎ. ΠΊΠ°ΠΊ ΡƒΡΡ‚Π°Π½ΠΎΠ²ΠΈΡ‚ΡŒ tkinter python windows-wish mac. ΠΊΠ°Ρ€Ρ‚ΠΈΠ½ΠΊΠ° ΠΊΠ°ΠΊ ΡƒΡΡ‚Π°Π½ΠΎΠ²ΠΈΡ‚ΡŒ tkinter python windows. ΠΊΠ°Ρ€Ρ‚ΠΈΠ½ΠΊΠ° wish mac. ΠΌΠΎΠΉ холостой бросаСт ошибки, ΠΊΠΎΡ‚ΠΎΡ€Ρ‹Π΅ ΠΈ Π³ΠΎΠ²ΠΎΡ€ΠΈΡ‚ tkinter Π½Π΅Π²ΠΎΠ·ΠΌΠΎΠΆΠ½ΠΎ ΠΈΠΌΠΏΠΎΡ€Ρ‚ΠΈΡ€ΠΎΠ²Π°Ρ‚ΡŒ.
The Wish application running on macOS.

For convenient use from the Unix command line, you’ll also find a script installed as /usr/local/bin/wish8.6 which will launch the same application.

To verify the exact version of Tcl/Tk that you are running, from the Wish console type the following:

We want this to be returning something like ‘8.6.9’.

Verified install using ActiveTcl 8.6.9.8609.2 on macOS 10.15.6.

Install Tk for Ruby (Ruby/Tk) on macOS

While previous versions of macOS included both Ruby and Tk (albeit older 8.4 versions), since Snow Leopard this has no longer been the case.

Ruby/Tk is a binding that links against an existing but separate Tk library. So, to get the latest version of Tk for Ruby, we’re going to have to do first download the latest 8.6.x Tcl/Tk version from ActiveState.

Install ActiveTcl

The «ActiveTcl» distribution from ActiveState contains the latest Tk, as well as the latest version of Tcl (which Ruby’s Tk bindings use internally to talk to Tk). In your web browser, go to www.activestate.com, and follow along the links to download the Community Edition of ActiveTcl. Note that you will need to create an account with ActiveState (no cost) to download it. Again, make sure you’re downloading an 8.6.x version.

Run the installer and everything will be loaded onto your machine.

Install Ruby

Next, you’ll want to install Ruby. There are multiple ways to do this, as explained at www.ruby-lang.org. One option is to use a package manager like Homebrew. Once it’s been installed (at /usr/local/bin/brew ) you can install Ruby from a command prompt (e.g. Terminal) via:

The initial «%» is the Unix shell prompt; you don’t have to type it.

Install Ruby/Tk

Next, you’ll need to download and install Ruby’s Tk module, which is packaged as a Ruby gem. To do so, from the command prompt, run:

To verify that everything worked, start up /usr/local/opt/ruby/bin/irb and type:

The first line should load Ruby/Tk; typically if there was a problem with finding Tcl/Tk it would show up here. The second line will return the version of Tk that you’re running, which should be something like «8.6.9».

Verified install using ActiveTcl 8.6.9.8609.2 and Ruby 2.7.1 via Homebrew on macOS 10.15.6.

Install Tk for Perl (Tkx) on macOS

For modern Tk programming using Perl, the «Tkx» module is highly recommended, and we’ll be using that here. It links against an existing but separate Tk library. So, to get the latest version of Tk for Perl, we’re going to have to do first download the latest 8.6.x Tcl/Tk version from ActiveState.

This tutorial used to rely on the ActivePerl distribution from ActiveState, which bundled a full Tcl/Tk installation, as well as the Tkx module. Unfortunately, as of this writing, there is not a macOS version of ActivePerl available.

Install ActiveTcl

The «ActiveTcl» distribution from ActiveState contains the latest Tk, as well as the latest version of Tcl (which Perl’s Tk bindings use internally to talk to Tk). In your web browser, go to www.activestate.com, and follow along the links to download the Community Edition of ActiveTcl. Note that you will need to create an account with ActiveState (no cost) to download it. Again, make sure you’re downloading an 8.6.x version.

Run the installer and everything will be loaded onto your machine.

Install Perl

Next, you’ll want to install Perl. There are multiple ways to do this, as explained at www.perl.org. One option is to use a package manager like Homebrew. Once it’s been installed (at /usr/local/bin/brew ) you can install Ruby from a command prompt (e.g. Terminal) via:

The initial «%» is the Unix shell prompt; you don’t have to type it.

Install Tkx

Next, you’ll need to download and install Perl’s Tkx module. We can grab it from CPAN. Unfortunately, at present it will not install correctly due to errors in its tests. We can bypass the tests and install it anyway. To do so, from the command prompt, run:

To check that this worked, run this from the Unix command line:

This will return the version of Tcl/Tk that it found. It should be something like «8.6.9».

Verified install using ActiveTcl 8.6.9.8609.2 and Perl 5.32.0 via Homebrew on macOS 10.15.6.

Installing Tk on Windows

Install Tk for Python (Tkinter) on Windows

Tkinter (and, since Python 3.1, ttk, which is the interface to the newer themed widgets) is included in the Python standard library. We highly recommend installing Python using the standard binary distributions from python.org. These will automatically install Tcl/Tk, which of course, is needed by Tkinter.

If you’re instead building Python from source code, the Visual Studio projects included in the «PCbuild» directory can automatically fetch and compile Tcl/Tk on your system.

Once you’ve installed or compiled Python, test it out to make sure Tkinter works. From the Python prompt, enter these two commands:

This should pop up a small window; the first line at the top of the window should say «This is Tcl/Tk version 8.6»; make sure it is not 8.4 or 8.5!

You can also get the exact version of Tcl/Tk that is being used with:

It should return something like ‘8.6.9’.

Verified using Python 3.9.0rc1 binary installer from python.org (containing Tcl/Tk 8.6.9) on Windows 10 version 1809.

Install Tk for Tcl on Windows

On Windows, the easiest way to get Tcl/Tk onto your machine is to install the «ActiveTcl» distribution from ActiveState, which includes Tcl, Tk, plus a number of other extension libraries.

In your web browser, go to www.activestate.com, and follow along the links to download the Community Edition of ActiveTcl for Windows. Make sure you’re downloading an 8.6.x version. Note that you will need to create an account with ActiveState (no cost) to download it.

Run the installer, and follow along. You’ll end up with a fresh install of ActiveTcl, usually located in C:\ActiveTcl. From a command prompt, you should then be able to run a Tcl/Tk 8.6 shell via:

This should pop up a small window titled «wish», which will contain your application. A second, larger window titled «Console» is where you can type in Tcl/Tk commands. To verify the exact version of Tcl/Tk that you are running, type the following:

We want this to be returning something like ‘8.6.9’.

Type «exit» in the console window to exit. You may also want to add C:\ActiveTcl\bin to your PATH environment variable.

Verified install using ActiveTcl 8.6.9.8609-2 on Windows 10.

Install Tk for Ruby (Ruby/Tk) on Windows

Luckily, it is now only mildly painful, thanks to the good folks behind RubyInstaller for Windows.

The one-click installer used to include everything you needed to run Ruby/Tk, including the underlying Tcl/Tk libraries. Unfortunately, Tk was removed from the Ruby standard library (stdlib) in version 2.4, and made available as an external gem. RubyInstaller followed suit.

Install ActiveTcl

First, you’ll need to install Tcl/Tk.

On Windows, the easiest way to get Tcl/Tk onto your machine is to install the «ActiveTcl» distribution from ActiveState, which includes Tcl, Tk, plus a number of other extension libraries.

In your web browser, go to www.activestate.com, and follow along the links to download the Community Edition of ActiveTcl for Windows. Make sure you’re downloading an 8.6.x version. Note that you will need to create an account with ActiveState (no cost) to download it.

Run the installer, and follow along. You’ll end up with a fresh install of ActiveTcl in C:\ActiveTcl.

Install Ruby

Install Ruby/Tk

Next, you’ll need to download and install Ruby’s Tk module, which is packaged as a Ruby gem. To do so, open a command prompt and run:

The initial «%» is the Unix shell prompt; you don’t have to type it.

Tell Ruby Where to Find ActiveTcl

You’re not done yet. If you try to use Tk from Ruby, it will complain that it can’t find the underlying Tcl/Tk libraries. We’ll need to do a couple of things to fix that.

Second, the Tcl and Tk shared libraries will look for a bunch of initialization and other scripts which were installed as part of ActiveTcl. The best way to specify where to find them is to set the TCL_LIBRARY and TK_LIBRARY system environment variables.

This can be done in the Windows control panel (or search for «system environment variables» from the taskbar). In Windows 10, you’ll find a button labelled «Environment Variables. » in the «Advanced» tab of «System Properties». Add these system variables:

If you’re running a shell via command prompt you’ll need to restart it to see those new additions.

To verify the version of Tk, start up your newly installed copy of ‘irb’ (which would have been installed in C:\Ruby26\bin ), and type:

The first line should load Ruby/Tk. The second line will return the version of Tk that you’re running, which should be something like «8.6.9».

Verified install using ActiveTcl 8.6.9.8609-2, RubyInstaller Ruby+DevKit 2.6.6-1 on Windows 10 version 1809.

Install Tk for Perl (Tkx) on Windows

For modern Tk programming using Perl, the «Tkx» module is highly recommended, and we’ll be using that here. The easiest way to get set up is to use the «ActivePerl» distribution from www.activestate.com.

The «ActivePerl» distribution from ActiveState includes not only Perl, but also recent versions of Tk and Tcl (which Tkx uses internally to talk to Tk). In your web browser, go to www.activestate.com, and follow along the links to download the Community Edition of ActivePerl. Note that you will need to create an account with ActiveState (no cost) to download it.

Run the installer and everything will be loaded onto your machine. On our machine, perl.exe was installed at «C:\Perl64\bin»

To find out what version of Tk Perl and Tkx are using, run this from the Windows command prompt:

We want this to be returning something like «8.5.13».

Versions of ActivePerl prior to 5.10 (and some of the first 5.10 builds) included earlier versions of Tcl/Tk (8.4.x rather than 8.5.x). Use a more recent version, and and verify that you do have Tk 8.5 or newer.

Verified install using ActivePerl 5.28 on Windows 10 version 1809.

Installing Tk on Linux

Install Tk for Python (Tkinter) on Linux/X11

Tkinter (and, since Python 3.1, ttk, which is the interface to the newer themed widgets) is included in the Python standard library. It relies on Tcl/Tk being installed on your system. Depending on how you install Python, this may not happen automatically.

Remember, we’re using Python 3.x here, not 2.x.

You have several different options to get Python and Tkinter onto your machine. We’ll show you two, using your distro’s package manager, or compiling from source.

Option 1. Your Linux Distribution’s Package Manager

However, after you’re done installing Python, you should verify that Tkinter works correctly. Start up a Python shell (e.g. /usr/bin/python3 ) and verify the install (see below).

If you’re getting an error saying «No module named tkinter» (without the single quotes around the module name), you’re probably using Python 2. This tutorial assumes Python 3.

Sometimes Linux distributions separate out their Tkinter support into a separate package. That saves installing the Tcl/Tk libraries for people who are using Python but not Tkinter. If so, you’ll need to find and install this package, which will also ensure that an appropriate version of the Tcl/Tk libraries are installed on your system.

For example, running Ubuntu 20.04LTS, Python 3.8.2 is already installed. However, to use Tkinter, you need to install a separate package, named python3-tk :

In this case, that package provides Tcl/Tk 8.6.x libraries to be used with Python.

Option 2. Install Tcl/Tk and Compile the Standard Python Distribution

If you’d like to use the standard source distribution from python.org, you can certainly do that.

But to do so, you’ll need to get the Tcl and Tk include files and libraries loaded on your machine first. Again, while there are several ways to do that, the easiest is to download and install ActiveTcl.

Another option would be to install the Tk development package, e.g. tk8.6-dev via your package manager.

Next, download the current Python 3.x source distribution from python.org, and unpack it. On your configure line, you’ll need to tell it how to find the version of Tcl/Tk you installed. Then build as usual:

Make sure to verify your install (see below).

Didn’t work? There may have been an error compiling Python’s tkinter code. To check, from the main Python source directory, try touch Modules/_tkinter.c (note the underscore) and then make to recompile it. Watch closely for error messages.

Verifying your Install

At the Python command prompt, enter these two commands:

This should pop up a small window; the first line at the top of the window should say «This is Tcl/Tk version 8.6»; make sure it is not 8.4!

If it gives you an error when you try to import tkinter (e.g. «If this fails your Python may not be configured for Tk»), something hasn’t been set up correctly. If you compiled Python yourself, see above to check for compile errors.

You can also get the exact version of Tcl/Tk that is being used with:

It should return something like ‘8.6.9’.

Verified install using ActiveTcl 8.6.9.8609.2 and Python 3.90rc1 source code from python.org on Ubuntu 20.04LTS.

Install Tk for Tcl on Linux/X11

Using a Package Manager

Using ActiveTcl

Another option is to install the «ActiveTcl» distribution from ActiveState, which includes Tcl, Tk, plus a number of other extension libraries.

In your web browser, go to www.activestate.com, and follow along the links to download the Community Edition of ActiveTcl for Linux. Make sure you’re downloading an 8.6.x version. Note that you will need to create an account with ActiveState (no cost) to download it.

This should pop up a window titled «wish8.6». To verify the exact version of Tcl/Tk that you are running, from the Wish prompt (in the terminal window) type the following:

We want this to be returning something like ‘8.6.9’. Type a control-D at the prompt in the terminal window to exit. You may also want to add /opt/ActiveTcl-8.6/bin to your Unix path.

Verified install using ActiveTcl 8.6.9.8609.2 on Ubuntu 20.04LTS.

Install Tk for Ruby (Ruby/Tk) on Linux/X11

To get Ruby/Tk working on Linux, we’ll rely on your distribution’s package manager. The package names and commands shown here are for Ubuntu, and may be different on your system.

Because Ruby/Tk is an add-on gem, it needs to be compiled on your system. That means we’re going to need to install the development versions of the Tcl/Tk libraries ( tk8.6-dev ) as well as Ruby ( ruby2.7-dev plus ruby2.7 for the command-line tools like irb and gem ]). This will also ensure we have the necessary compilers, dependent libraries like X11, and so on.

The initial «%» is the Unix shell prompt; you don’t have to type it.

Finally, you can install the Ruby/Tk binding with:

To verify that everything worked, start up irb and type:

The first line should load Ruby/Tk; typically if there was a problem with compiling it would show up here. The second line will return the version of Tk that you’re running, which should be something like «8.6.10».

Verified install using tk8.6-dev 8.6.10-1, ruby2.7.0 on Ubuntu 20.04LTS.

Install Tk for Perl (Tkx) on Linux/X11

For modern Tk programming using Perl, the «Tkx» module is highly recommended, and we’ll be using that here. The easiest way to get set up is to use the «ActivePerl» distribution from www.activestate.com.

The «ActivePerl» distribution from ActiveState includes not only Perl, but also recent versions of Tk and Tcl (which Tkx uses internally to talk to Tk). In your web browser, go to www.activestate.com, and follow along the links to download the Community Edition of ActivePerl. Note that you will need to create an account with ActiveState (no cost) to download it.

Run the installer and everything will be loaded onto your machine, in e.g. /opt/ActivePerl-5.28.

To find out what version of Tk Perl and Tkx are using, run this from the command line:

We want this to be returning something like «8.5.13».

Versions of ActivePerl prior to 5.10 (and some of the first 5.10 builds) included earlier versions of Tcl/Tk (8.4.x rather than 8.5.x). Use a more recent version, and and verify that you do have Tk 8.5 or newer.

Verified install using ActivePerl 5.28.1 on Ubuntu 20.04LTS.

The Obligatory First Program

To make sure that everything actually did work, let’s try to run a «Hello World» program in Tk. While for something this short, you could just type it in directly to the interpreter, instead use your favorite text editor to put it in a file.

Save this to a file named «hello.py». From a command prompt, type:

Couldn’t find hello.py? You might be looking in the wrong directory. Try providing the full path to hello.py.

Save this to a file named «hello.tcl». From the wish shell, type:

Couldn’t find hello.tcl? You might be looking in the wrong directory. You can either give the full path to hello.tcl, or use Tcl’s pwd and cd commands to see what directory you’re in, and change to a different one.

Save this to a file named «hello.rb». Start up [tk::inl «irb»], and from the command prompt, type:

Couldn’t find hello.rb? You might be looking in the wrong directory. You can either give the full path to hello.rb, or use Ruby’s Dir.pwd and Dir.chdir commands to see what directory you’re in, and change to a different one.

Note that there are two underscores between «ttk» and «button».

Save this to a file named «hello.pl». From a command prompt, type:

Couldn’t find hello.pl? You might be looking in the wrong directory. Try providing the full path to hello.pl.

Not working? Are you sure you’re using an 8.5 or newer version of Tcl/Tk? See the install chapter.

ΠΊΠ°ΠΊ ΡƒΡΡ‚Π°Π½ΠΎΠ²ΠΈΡ‚ΡŒ tkinter python windows. hello all. ΠΊΠ°ΠΊ ΡƒΡΡ‚Π°Π½ΠΎΠ²ΠΈΡ‚ΡŒ tkinter python windows Ρ„ΠΎΡ‚ΠΎ. ΠΊΠ°ΠΊ ΡƒΡΡ‚Π°Π½ΠΎΠ²ΠΈΡ‚ΡŒ tkinter python windows-hello all. ΠΊΠ°Ρ€Ρ‚ΠΈΠ½ΠΊΠ° ΠΊΠ°ΠΊ ΡƒΡΡ‚Π°Π½ΠΎΠ²ΠΈΡ‚ΡŒ tkinter python windows. ΠΊΠ°Ρ€Ρ‚ΠΈΠ½ΠΊΠ° hello all. ΠΌΠΎΠΉ холостой бросаСт ошибки, ΠΊΠΎΡ‚ΠΎΡ€Ρ‹Π΅ ΠΈ Π³ΠΎΠ²ΠΎΡ€ΠΈΡ‚ tkinter Π½Π΅Π²ΠΎΠ·ΠΌΠΎΠΆΠ½ΠΎ ΠΈΠΌΠΏΠΎΡ€Ρ‚ΠΈΡ€ΠΎΠ²Π°Ρ‚ΡŒ.
Our first program. Some work left to do before the IPO.

Spotted a mistake? Couldn’t find what you were looking for? Suggestions? Let me know!
If you’ve found this tutorial useful, please check out Modern Tkinter.

Π˜ΡΡ‚ΠΎΡ‡Π½ΠΈΠΊ

Π”ΠΎΠ±Π°Π²ΠΈΡ‚ΡŒ ΠΊΠΎΠΌΠΌΠ΅Π½Ρ‚Π°Ρ€ΠΈΠΉ

Π’Π°Ρˆ адрСс email Π½Π΅ Π±ΡƒΠ΄Π΅Ρ‚ ΠΎΠΏΡƒΠ±Π»ΠΈΠΊΠΎΠ²Π°Π½. ΠžΠ±ΡΠ·Π°Ρ‚Π΅Π»ΡŒΠ½Ρ‹Π΅ поля ΠΏΠΎΠΌΠ΅Ρ‡Π΅Π½Ρ‹ *