Building importable _tkinter on Windows


Terry Reedy

If you have tried to build _tkinter on Windows from the cpython
repository, and have 'import tkinter' work, please share your
experience, successful or not. I and another person have both failed.

Following the directions in the devguide (and for one step,
PCBuild/readme), I did essentially the following.

* download and install TortoiseHG and an svn client (for external.bat)
* download and install c++ 2010 express
* in directory X, clone the hg repository as cpython
* in X/cpython, run Tools/buildbot/external.bat to fetch and compile
tcl/tk and other external dependencies.
* run visual studio with X/cpython/PCBuild/pcbuild.sln (I just double
click on the .sln file. Choose c++ 2010 if other compilers are listed.

* build debug version of 3.4 (F7), stored as .../PCBuild/python_d.exe.
This also builds in the same directory things like _bz2_d.pyd and
_lzma_d.pyd (whose dependencies are also fetched by external.bat) and
_tkinter_d.pyd, apparently without error. The last is 43 kb. That is
smaller than the others, but reasonable considering that it just
forwards calls to tk. My installed 3.3 _tkinter.pyd is 41 kb.

* run python_d.exe. sys.path is
'F:\\Python\\dev\\cpython\\PCbuild', # where _tkinter, etc are
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "F:\Python\dev\cpython\lib\tkinter\", line 36, in
from tkinter import _fix
File "F:\Python\dev\cpython\lib\tkinter\", line 65, in <module>
import _tkinter
ImportError: DLL load failed: The specified module could not be found.
[83479 refs, 32096 blocks]

My two hypotheses:

1. There is something wrong with _tkinter_d.pyd in particular such that
it is not recognized as a dll file. To test this, I renamed my installed
_tkinter, copied and renamed _tkinter_d, ran installed python 3.3, and
got a similar error
ImportError: DLL load failed: %1 is not a valid Win32 application.
Perhaps this verifies the hypothesis, perhaps it is due to a mismatch
between normal builds and debug builds.

2. CPython somehow special-cases the _tkinter import so that it fails in
the fresh build environment. This seems dubious, but who knows?

Since the Windows buildbots build and test cpython more or less the same
way, test/test_tkinter should pick up the same problem -- *if* it is
actually run, but because of some problems with the test suite, I am not
sure it is, rather than being skipped. Or maybe there is some
significant small different in the buildbot process.

Does anyone have any idea what else I might do?

I expect to eventually post on pydev or the tracker, but I wanted to
first try to collect more information here (which I wish more people
would do).


Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question