Repository navigation
Description
Description
macos-11 environment is missing Tcl/Tk 8.6 shared libraries (/usr/local/lib/libtcl8.6.dylib and /usr/local/lib/libtk8.6.dylib) that are required by tkinter module in python >= 3.10.1 builds from actions/python-versions.
Consequently, tkinter cannot be used with python >= 3.10.1 on macos-11, e.g., running python3 -c 'import tkinter' results in
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/Users/runner/hostedtoolcache/Python/3.10.2/x64/lib/python3.10/tkinter/__init__.py", line 37, in <module>
import _tkinter # If this fails your Python may not be configured for Tk
ImportError: dlopen(/Users/runner/hostedtoolcache/Python/3.10.2/x64/lib/python3.10/lib-dynload/_tkinter.cpython-310-darwin.so, 2): Library not loaded: /usr/local/lib/libtk8.6.dylib
Referenced from: /Users/runner/hostedtoolcache/Python/3.10.2/x64/lib/python3.10/lib-dynload/_tkinter.cpython-310-darwin.so
Reason: image not found
The earlier python builds (python <= 3.10.0) were built against (outdated) system Tcl/Tk 8.5 frameworks, but starting with 3.10.1, the _tkinter module is linked against Tcl/Tk 8.6 shared libraries that are supposed to be located in /usr/local/lib. These shared libraries are present on macos-10.15, but are missing from macos-11.
The same issue was reported here: actions/setup-python#314. There, there is some confusion over inconsistent behavior, i.e., tkinter working in some repositories and not in some, which stems from macos-latest sometimes still translating to macos-10.15 (where the issue is not present).
Virtual environments affected
- Ubuntu 18.04
- Ubuntu 20.04
- macOS 10.15
- macOS 11
- Windows Server 2016
- Windows Server 2019
- Windows Server 2022
Image version and build link
20220118.8
Example of failed job(s): https://github.com/pyinstaller/pyinstaller/runs/4898415211?check_suite_focus=true
The above example shows that:
- Tcl/Tk 8.6 shared libraries are present in
macos-10.15image, but missing frommacos-11 tkinterfails to import under python 3.10.1 and 3.10.2 onmacos-11due to missing Tcl/Tk 8.6 shared librariestkinteris successfully imported under python 3.10.0 onmacos-11, because this build is still using old system-provided Tcl/Tk 8.5tkinteris successfuly imported under all three python 3.10 releases onmacos-10.15
Is it regression?
No response
Expected behavior
Tcl/Tk 8.6 shared libraries (/usr/local/lib/libtcl8.6.dylib and /usr/local/lib/libtk8.6.dylib) being present in the virtual image, and working tkinter in python >= 3.10.1.
Actual behavior
Tcl/Tk 8.6 shared libraries (/usr/local/lib/libtcl8.6.dylib and /usr/local/lib/libtk8.6.dylib) are missing from the virtual environment, resulting in defunct tkinter with python >= 3.10.1.
Repro steps
Basic job to reproduce the problem:
https://github.com/pyinstaller/pyinstaller/runs/4898415211?check_suite_focus=true
jobs:
tests:
runs-on: ${{ matrix.os }}
strategy:
matrix:
python-version: ['3.10.0', '3.10.1', '3.10.2']
os: ['macos-10.15', 'macos-11']
fail-fast: false
steps:
- uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Check for presence of Tcl/Tk 8.6 libraries
run: |
ls -l /usr/local/lib/libtcl* || echo "Tcl/Tk 8.6 not found!"
- name: Try importing tkinter
run: python3 -c 'import tkinter'
Activity
mikhailkoliada commentedon Jan 21, 2022
@rokm
Hello!
We will take a look. Could you please try this workaround in your workflow:
rokm commentedon Jan 21, 2022
I suppose for fully-working tkinter (or rather, what PyInstaller expects to find when bundling tkinter) in addition to those two shared libraries, the .tcl script directories
/usr/local/Cellar/tcl-tk/8.6.12_1/lib/{tcl8,tcl8.6,tk8.6}would also need to be symlinked.But it seems that on
macos-10.15, these files and directories are not symlinks to their equivalents in/usr/local/Cellar/tcl-tk/8.6.12/lib(in contrast to other .dylibs in/usr/local/lib, which in fact do point into/usr/local/Cellar).; see extended test run at https://github.com/pyinstaller/pyinstaller/runs/4898845758?check_suite_focus=truemikhailkoliada commentedon Jan 24, 2022
@rokm Hello!
Could you please be kind and elaborate on "fully" working tkinter a bit? The solution from the attached pull request makes tkinter importable (I've tested this on the minimal example you've provided), are there any more corner cases to be covered?
Thanks!
rokm commentedon Jan 24, 2022
@mikhailkoliada I was referring to the fact that the .tcl script directories (called
tcl8,tcl8.6, andtk8.6) are typically located next to the shared libraries. The minimal import example would likely not reveal their absence (and I'm not familiar with tkinter enough to provide an example that would do so). But on the other hand, this may not be a problem, because if I recall correctly, the "true location" of the shared libraries (i.e., the location used as a base for the search path) on macOS is the location of the library that the symlink points to, not the symlink itself.So I think the symlink solution should work. (It's a different question if it will work for PyInstaller, but if not, that's our problem, not yours).
mikhailkoliada commentedon Jan 25, 2022
The changes will be rolled out next week.
QuLogic commentedon Feb 3, 2022
In what image is this expected to be fixed? I thought it'd be this week's, but this build is using 20220201.3, but still fails to find
libtk8.6.dylibmiketimofeev commentedon Feb 7, 2022
@QuLogic sorry, we have found that another fix should have been implemented. The changes will be deployed this week.
QuLogic commentedon Feb 11, 2022
Only 99.9% deployed, but did manage to catch a new builder image which passes already.
mikhailkoliada commentedon Feb 11, 2022
Shall be done now.