Building importable _tkinter on Windows

Discussion in 'Python' started by Terry Reedy, Mar 10, 2013.

  1. Terry Reedy

    Terry Reedy Guest

    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 python.org 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\\python34_d.zip',
    'F:\\Python\\dev\\cpython\\DLLs',
    'F:\\Python\\dev\\cpython\\lib',
    'F:\\Python\\dev\\cpython\\PCbuild', # where _tkinter, etc are
    'F:\\Python\\dev\\cpython',
    'F:\\Python\\dev\\cpython\\lib\\site-packages']

    >>> import bz2, lzma # these import _bz2 and _lzma
    >>> import tkinter

    Traceback (most recent call last):
    File "<stdin>", line 1, in <module>
    File "F:\Python\dev\cpython\lib\tkinter\__init__.py", line 36, in
    <module>
    from tkinter import _fix
    File "F:\Python\dev\cpython\lib\tkinter\_fix.py", 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).

    --
    Terry Jan Reedy
    Terry Reedy, Mar 10, 2013
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    1
    Views:
    236
    =?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?=
    Apr 28, 2007
  2. Val
    Replies:
    2
    Views:
    369
  3. Robert P. J. Day

    how to check if a module is importable?

    Robert P. J. Day, Jan 20, 2010, in forum: Python
    Replies:
    2
    Views:
    241
    Robert P. J. Day
    Jan 20, 2010
  4. Daniel Berger
    Replies:
    3
    Views:
    110
    Daniel Berger
    Oct 30, 2004
  5. Terry Reedy
    Replies:
    0
    Views:
    97
    Terry Reedy
    Mar 10, 2013
Loading...

Share This Page