How to pip or easy_install tkinter on Windows

2019-01-13 09:23发布

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

Is there a simple way to install tkinter via pip or easy_install?

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

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

pip install python-tk

I'm on Windows with Python 2.7 and can't apt-get.

Thanks.

10条回答
兄弟一词,经得起流年.
2楼-- · 2019-01-13 10:05

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:

import Tkinter as tk

Note the capital T at the beginning of Tkinter.

For Python 3,

import tkinter as tk

查看更多
虎瘦雄心在
3楼-- · 2019-01-13 10:06

When installing make sure that under Tcl/Tk you select Will be installed on hard drive. If it is installing with a cross at the left then Tkinter will not be installed.

enter image description here

The same goes for Python 3:

enter image description here

查看更多
来,给爷笑一个
4楼-- · 2019-01-13 10:06

I solved the same problem using these two commands 100%

sudo yum -y update
sudo yum -y install python36u-tkinter
查看更多
等我变得足够好
5楼-- · 2019-01-13 10:07

When you install python for Windows, use the standard option or install everything it asks. I got the error because I deselected tcl.

查看更多
登录 后发表回答