Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot import _tkinter in Python 3.5 on Windows #68959

Closed
Drekin mannequin opened this issue Aug 1, 2015 · 8 comments
Closed

Cannot import _tkinter in Python 3.5 on Windows #68959

Drekin mannequin opened this issue Aug 1, 2015 · 8 comments
Assignees
Labels

Comments

@Drekin
Copy link
Mannequin

Drekin mannequin commented Aug 1, 2015

BPO 24771
Nosy @pfmoore, @larryhastings, @tjguk, @zware, @eryksun, @zooba

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = 'https://github.com/zooba'
closed_at = <Date 2015-08-03.23:25:49.672>
created_at = <Date 2015-08-01.09:01:22.353>
labels = ['type-bug', 'expert-tkinter', 'OS-windows', 'release-blocker']
title = 'Cannot import _tkinter in Python 3.5 on Windows'
updated_at = <Date 2015-08-03.23:25:49.671>
user = 'https://bugs.python.org/Drekin'

bugs.python.org fields:

activity = <Date 2015-08-03.23:25:49.671>
actor = 'steve.dower'
assignee = 'steve.dower'
closed = True
closed_date = <Date 2015-08-03.23:25:49.672>
closer = 'steve.dower'
components = ['Tkinter', 'Windows']
creation = <Date 2015-08-01.09:01:22.353>
creator = 'Drekin'
dependencies = []
files = []
hgrepos = []
issue_num = 24771
keywords = []
message_count = 8.0
messages = ['247802', '247822', '247824', '247830', '247839', '247840', '247965', '247966']
nosy_count = 8.0
nosy_names = ['paul.moore', 'larry', 'tim.golden', 'python-dev', 'zach.ware', 'eryksun', 'Drekin', 'steve.dower']
pr_nums = []
priority = 'release blocker'
resolution = 'fixed'
stage = 'resolved'
status = 'closed'
superseder = None
type = 'behavior'
url = 'https://bugs.python.org/issue24771'
versions = ['Python 3.5']

@Drekin
Copy link
Mannequin Author

Drekin mannequin commented Aug 1, 2015

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.

@Drekin Drekin mannequin added topic-tkinter OS-windows type-bug An unexpected behavior, bug, or error labels Aug 1, 2015
@eryksun
Copy link
Contributor

eryksun commented Aug 1, 2015

64-bit 3.5.0b4 works for me in Windows 7. Try loading _tkinter.pyd in Dependency Walker. 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)

@Drekin
Copy link
Mannequin Author

Drekin mannequin commented Aug 1, 2015

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).

@eryksun
Copy link
Contributor

eryksun commented Aug 1, 2015

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 bpo-24476. This needs to be changed in the TCL/Tk project files as well.

@zooba
Copy link
Member

zooba commented Aug 1, 2015

Correct. I'll fix this on Monday or Tuesday this week.

@zooba zooba self-assigned this Aug 1, 2015
@zooba
Copy link
Member

zooba commented Aug 1, 2015

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

@python-dev
Copy link
Mannequin

python-dev mannequin commented Aug 3, 2015

New changeset e9f91d47c8ab by Steve Dower in branch '3.5':
Issue bpo-24771: Adds vcruntime DLL to tcltk package
https://hg.python.org/cpython/rev/e9f91d47c8ab

New changeset 14dee84ab900 by Steve Dower in branch 'default':
Issue bpo-24771: Adds vcruntime DLL to tcltk package
https://hg.python.org/cpython/rev/14dee84ab900

@zooba
Copy link
Member

zooba commented Aug 3, 2015

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.

@zooba zooba closed this as completed Aug 3, 2015
@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants