This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Cannot import _tkinter in Python 3.5 on Windows
Type: behavior Stage: resolved
Components: Tkinter, Windows Versions: Python 3.5
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: steve.dower Nosy List: Drekin, eryksun, larry, paul.moore, python-dev, steve.dower, tim.golden, zach.ware
Priority: release blocker Keywords:

Created on 2015-08-01 09:01 by Drekin, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Messages (8)
msg247802 - (view) Author: Adam Bartoš (Drekin) * Date: 2015-08-01 09:01
I found out that I cannot import tkinter in Python 3.5.0b4 on 64-bit Windows Vista. Trying to import _tkinter results in ImportError: DLL load failed. On the other hand I have no problem importing _ctypes whose .pyd file is at the same location as _tkinter.pyd.
msg247822 - (view) Author: Eryk Sun (eryksun) * (Python triager) Date: 2015-08-01 19:34
64-bit 3.5.0b4 works for me in Windows 7. Try loading _tkinter.pyd in [Dependency Walker][1]. Or try loading the dependent DLLs directly via ctypes:

    import os
    import _ctypes

    dlls_path = os.path.dirname(_ctypes.__file__)
    for d in ('tcl86t.dll', 'tk86t.dll'):
        path = os.path.join(dlls_path, d)
        try:
            _ctypes.LoadLibrary(path)
        except OSError:
            print('failed:', path)

[1]: http://dependencywalker.com
msg247824 - (view) Author: Adam Bartoš (Drekin) * Date: 2015-08-01 20:24
It seems that both tcl86t.dll and tk86t.dll can be found, but their dependency VCRUNTIME140.dll cannot. For some reason, Dependency Walker cannot locate also python35.dll and ieshims.dll (but it tries to find all three libraries in Python 3.5\DLLs and at least python35.dll is located directly in Python 3.5 directory).
msg247830 - (view) Author: Eryk Sun (eryksun) * (Python triager) Date: 2015-08-01 21:25
Not finding python35.dll is normal since there's no activation context from python.exe. The vcruntime140 library is statically linked to avoid having to distribute vcruntime140.dll. See issue 24476. This needs to be changed in the TCL/Tk project files as well.
msg247839 - (view) Author: Steve Dower (steve.dower) * (Python committer) Date: 2015-08-01 23:47
Correct. I'll fix this on Monday or Tuesday this week.
msg247840 - (view) Author: Steve Dower (steve.dower) * (Python committer) Date: 2015-08-01 23:48
Until then, if you find and install the VC distributable for VS 2015 then you'll have the files you need. On my phone now so I don't have the link handy
msg247965 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2015-08-03 23:22
New changeset e9f91d47c8ab by Steve Dower in branch '3.5':
Issue #24771: Adds vcruntime DLL to tcltk package
https://hg.python.org/cpython/rev/e9f91d47c8ab

New changeset 14dee84ab900 by Steve Dower in branch 'default':
Issue #24771: Adds vcruntime DLL to tcltk package
https://hg.python.org/cpython/rev/14dee84ab900
msg247966 - (view) Author: Steve Dower (steve.dower) * (Python committer) Date: 2015-08-03 23:25
Rather than change the tcl and tk project files (which is not as easy as updating the Python projects - I spent an hour trying), I've added the vcruntime DLL to the MSI with tkinter.

Distutils has already been updated to not include it any more, and I really want to avoid having people depend on it since it could break the nice compatibility we have going now, but there's no easy way around it right now.
History
Date User Action Args
2022-04-11 14:58:19adminsetgithub: 68959
2015-08-03 23:25:49steve.dowersetstatus: open -> closed
resolution: fixed
messages: + msg247966

stage: resolved
2015-08-03 23:22:44python-devsetnosy: + python-dev
messages: + msg247965
2015-08-01 23:48:11steve.dowersetmessages: + msg247840
2015-08-01 23:47:19steve.dowersetassignee: steve.dower
messages: + msg247839
2015-08-01 21:25:45eryksunsetmessages: + msg247830
2015-08-01 20:24:06Drekinsetmessages: + msg247824
2015-08-01 19:34:20eryksunsetnosy: + eryksun
messages: + msg247822
2015-08-01 10:50:22serhiy.storchakasetpriority: normal -> release blocker
nosy: + larry
2015-08-01 09:01:22Drekincreate