Skip to main content

Using Tkinter and IDLE with PyPy

We are pleased to announce that Tkinter, the GUI library based on TCL/TK, now works with PyPy.
Tkinter is composed of two parts:

  • _tkinter, a module written in C which interfaces with the TCL world
  • Tkinter, a pure Python package which wraps _tkinter to expose the pythonic API we are used to
The PyPy version of _tkinter reuses the C code of as found in CPython and compile it through the PyPy C-API compatibility layer, cpyext. To make it work with PyPy, we had to modify it slightly, in order to remove the dependency on some API functions which are not supported by PyPy. In particular, we removed the dependency on the PyOS_InputHook variable, which allows a nice integration of Tkinter and the Python interactive prompt: the result is that, unlike CPython, in PyPy Tk windows created at the interactive prompt are not shown until we manually call the mainloop method. Apart from this inconvenience, all the rest works fine.
At the moment, _tkinter is not distributed with PyPy because our build system does not support automatic compilation of C extension. Instead, it is necessary to install it manually, either directly from source or by easy_installing/pip installing tkinter-pypy from PyPI.
For everything to work correctly, you need a recent build of PyPy: the following is a step-by-step guide to install _tkinter in a PyPy nightly build for Linux 64 bit; for other architectures, look at the nightly build page:
$ wget

$ tar xfv pypy-c-jit-43485-1615dfd7d8f1-linux64.tar.bz2

$ cd pypy-c-jit-43485-1615dfd7d8f1-linux64/

$ wget

$ ./bin/pypy    # install setuptools

$ ./bin/easy_install tkinter-pypy
Once you complete the steps above, you can start using Tkinter from your python programs. In particular, you can use IDLE, the IDE which is part of the Python standard library. To start IDLE, type:
$ ./bin/pypy -m idlelib.idle
Have fun :-)


Unknown wrote on 2011-04-20 15:09:

It is sooo ancient. I'd think twice before bundling anything potentially exploitable (read - compiled C modules) with PyPy.

RonnyPfannschmidt wrote on 2011-04-20 22:59:

i fail to see how this is more exploitable than say ctypes (which is already shipped)

Brandon Corfman wrote on 2011-04-22 17:01:

I'm really REALLY happy about this ... Tkinter, multiprocessing, and 2.7 support were my remaining roadblocks to using PyPy. I'm d/l now to give it a try with Raven Checkers. I hope that I won't need to look back.

Joaquin Abian wrote on 2011-05-13 20:41:

I tried to install tkinter on win 7. When I do pypy I get a traceback that finish with:

File "", line 212, in main
from setuptools.command.easy_install import main
ZipImportError: 'setuptools.command.install'

Some hint on how to solve it?

Antonio Cuni wrote on 2011-05-18 15:13:

indeed, ez_setup seems not to work on windows. It might be related to this, although I did not investigate further:

Instead of ez_setup, you can try to follow these instructions and install distribute/pip, which we recommend anyway nowadays:

Note however that tkinter-pypy is not precompiled for windows, so you need to have the necessary developer tools installed. If you manage to build a precompiled binary of tkinter-pypy, I'd be happy to put it in pypi :-)

Anonymous wrote on 2011-11-24 16:52:

Seems that tcl8.4-dev and tk8.4-dev needs to be installed!
This should be insert into the "install instruction" ;)

Daniel Petti wrote on 2012-05-29 19:01:

What does "command 'cc' failed with error 1" mean? I keep getting that upon installing tkinter-pypy

Anonymous wrote on 2012-10-22 17:27:

I'm unable to compile it on Windows (MinGW and also tried with VS 2010). Getting the following error:

fatal error: tcl.h: No such file or directory

My TCL installed under a different directory. How can I point the compiler to use tcl.h file from that directory?

Rich Wandell wrote on 2013-05-03 14:47:

I am having an incredible amount of problems attempting to build tkinter for pypy on windows. Is there anywhere I can download a pre built version?

Anonymous wrote on 2013-10-28 18:14:

This is outdated. But how to use Tkinter currently under windows?

Unknown wrote on 2014-02-02 11:18:

I think I've managed to compile Tkinter for Windows. Could anyone interested please try it out? Just download this archive and extract it into your Pypy folder:

Luis wrote on 2014-05-11 22:35:

XJDHDR: The link is not working. Do you still have the file available to download?

Unknown wrote on 2014-05-12 17:27:

The file is still available. Try this link:

Dropbox must have changed something on their end.