Search code examples
pythonpython-2.7tkinterpipeasy-install

How to pip or easy_install tkinter on Windows


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. This is what I run:

pip install python-tk

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


Solution

  • Well I can see two solutions here:

    1) Follow the Docs-Tkinter install for Python (for Windows):

    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.

    Run the installer, and follow along. You'll end up with a fresh install of ActivePython, located in, e.g. C:\python32. From a Windows command prompt, or the Start Menu's "Run..." command, you should then be able to run a Python shell via:

    % C:\python32\python
    

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

    >>> import tkinter
    >>> tkinter._test()
    

    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.