Skip to content

macos-11 is missing Tcl/Tk 8.6 shared libraries required by python >= 3.10.1 #4931

Closed

Description

@rokm

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.15 image, but missing from macos-11
  • tkinter fails to import under python 3.10.1 and 3.10.2 on macos-11 due to missing Tcl/Tk 8.6 shared libraries
  • tkinter is successfully imported under python 3.10.0 on macos-11, because this build is still using old system-provided Tcl/Tk 8.5
  • tkinter is successfuly imported under all three python 3.10 releases on macos-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

  1. mikhailkoliada commented on Jan 21, 2022

    @mikhailkoliada
    Contributor

    @rokm

    Hello!
    We will take a look. Could you please try this workaround in your workflow:

        ln -s /usr/local/Cellar/tcl-tk/$version/lib/libtcl8.6.dylib /usr/local/lib/libtcl8.6.dylib
        ln -s /usr/local/Cellar/tcl-tk/$version/lib/libtk8.6.dylib /usr/local/lib/libtk8.6.dylib
    
  2. rokm commented on Jan 21, 2022

    @rokm
    Author

    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=true

  3. mikhailkoliada commented on Jan 24, 2022

    @mikhailkoliada
    Contributor

    @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!

  4. rokm commented on Jan 24, 2022

    @rokm
    Author

    @mikhailkoliada I was referring to the fact that the .tcl script directories (called tcl8,tcl8.6, and tk8.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).

  5. mikhailkoliada commented on Jan 25, 2022

    @mikhailkoliada
    Contributor

    The changes will be rolled out next week.

  6. QuLogic commented on Feb 3, 2022

    @QuLogic

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

  7. added and removed
    awaiting-deploymentCode complete; awaiting deployment and/or deployment in progress
    on Feb 4, 2022
  8. miketimofeev commented on Feb 7, 2022

    @miketimofeev
    Contributor

    @QuLogic sorry, we have found that another fix should have been implemented. The changes will be deployed this week.

  9. QuLogic commented on Feb 11, 2022

    @QuLogic

    Only 99.9% deployed, but did manage to catch a new builder image which passes already.

  10. mikhailkoliada commented on Feb 11, 2022

    @mikhailkoliada
    Contributor

    Shall be done now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions