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

macos-13 Python can't find Tcl/Tk 8.6 shared libraries #11074

Open
2 of 15 tasks
WeisLeDocto opened this issue Dec 2, 2024 · 6 comments
Open
2 of 15 tasks

macos-13 Python can't find Tcl/Tk 8.6 shared libraries #11074

WeisLeDocto opened this issue Dec 2, 2024 · 6 comments

Comments

@WeisLeDocto
Copy link

WeisLeDocto commented Dec 2, 2024

Description

Hi !

I'm experiencing a similar issue on macos-13 runner as described in #6442 for macos-12 and #4931 for macos-11.
Basically, Python fails to find libtcl8.6.dylib in all the locations in tries.

Unlike the referenced issues, the bug is not solved by adding the symlinks suggested in #4931.
(I still added them in the minimal repro example for demonstration)

I'm demonstrating the issue with Python 3.9, but I'm also experiencing it for versions 3.7, 3.8 and 3.10.

Platforms affected

  • Azure DevOps
  • GitHub Actions - Standard Runners
  • GitHub Actions - Larger Runners

Runner images affected

  • Ubuntu 20.04
  • Ubuntu 22.04
  • Ubuntu 24.04
  • macOS 12
  • macOS 13
  • macOS 13 Arm64
  • macOS 14
  • macOS 14 Arm64
  • macOS 15
  • macOS 15 Arm64
  • Windows Server 2019
  • Windows Server 2022

Image version and build link

Version: 20241125.399
https://github.com/TissueEngineeringLab/MyoFInDer/actions/runs/12116070585/job/33775709298

Is it regression?

Yes
Version: 20241023.237
Not exactly the same workflow, but symlink could be found by Python.
import tkinter is included in the import myofinder call, in the Import MyoFInDer step.
Link: https://github.com/TissueEngineeringLab/MyoFInDer/actions/runs/11629304885/job/32386049285

Expected behavior

tkinter can be imported in Python

Actual behavior

import tkinter crashes with error:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/Users/runner/hostedtoolcache/Python/3.9.20/x64/lib/python3.9/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.9.20/x64/lib/python3.9/lib-dynload/_tkinter.cpython-39-darwin.so, 0x0002): Library not loaded: /usr/local/opt/tcl-tk/lib/libtcl8.6.dylib
  Referenced from: <0E547FD7-F776-378C-B4DE-8D241CDFE19E> /Users/runner/hostedtoolcache/Python/3.9.20/x64/lib/python3.9/lib-dynload/_tkinter.cpython-39-darwin.so
  Reason: tried: '/usr/local/opt/tcl-tk/lib/libtcl8.6.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/usr/local/opt/tcl-tk/lib/libtcl8.6.dylib' (no such file), '/usr/local/opt/tcl-tk/lib/libtcl8.6.dylib' (no such file), '/usr/local/lib/libtcl8.6.dylib' (no such file), '/usr/lib/libtcl8.6.dylib' (no such file, not in dyld cache), '/usr/local/Cellar/tcl-tk/9.0.0_1/lib/libtcl8.6.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/usr/local/Cellar/tcl-tk/9.0.0_1/lib/libtcl8.6.dylib' (no such file), '/usr/local/Cellar/tcl-tk/9.0.0_1/lib/libtcl8.6.dylib' (no such file), '/usr/local/lib/libtcl8.6.dylib' (no such file), '/usr/lib/libtcl8.6.dylib' (no such file, not in dyld cache)

Repro steps

Note that the brew install tcl-tk step was not included in the last successful run, I added it in my minimal example to make sure tcl/tk is installed

name: tkinter minimal

on:
  workflow_dispatch:

jobs:
  minimal:
    runs-on: macos-13
    steps:
        - name: Install Python
          uses: actions/setup-python@v5
          with:
            python-version: "3.9"
        - name: Install tcl/tk
          run: brew install tcl-tk
        - name: Symlink tcl/tk
          run: |
            version=$(brew info tcl-tk --json | jq -r '.[].installed[].version')
            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
        - name: Install python-tk
          run: brew install [email protected]
        - name: import tkinter
          run: python -c "import tkinter"
@pravinade
Copy link

Hi @WeisLeDocto ,

Thank you for your patience and for bringing this to our attention. We are currently working on a solution to address the issue you're facing. We ask that you bear with us while we resolve it.

In the meantime, if you have any additional information or questions, feel free to let us know. We appreciate your understanding and will keep you updated as we make progress.

@pravinade
Copy link

The issue you’re encountering might be due to the fact that the python -c "import tkinter" command works fine for all our macOS runner images, including macOS-13 and macOS-14. This is because these images come pre-configured with the necessary Tcl/Tk libraries, so Python can directly use the already installed version of Tcl/Tk without requiring manual installation or symlink creation.

In fact, if you use the following simple python -c "import tkinter" command, it should work without additional setup:


on:
  workflow_dispatch:

jobs:
  build:
    strategy:
      fail-fast: false
      matrix:
        os: ['macos-13', 'macos-13-xlarge', 'macos-14', 'macos-14-large']

    runs-on: ${{ matrix.os }}
    steps:
      - name: Import Tkinter
        run: |
          python -c "import tkinter; print(f'Tkinter imported successfully. Version: {tkinter.TkVersion}')"

this command ensures that tkinter imports and outputs the version successfully using the pre-installed libraries available in the runner image.
If you are still encountering issues, please feel free to share your workflow file, and we can take a closer look!

@WeisLeDocto
Copy link
Author

Thank you for your swift reply.
Indeed, the following workflow runs smoothly:

name: tkinter minimal

on:
  workflow_dispatch:

jobs:
  minimal:
    runs-on: macos-13
    steps:
      - name: import tkinter
        run: python -c "import tkinter"

I should've tried that first. 😅

However, the only Python version installed by default is 3.13 (checked using ls /usr/bin/python* in a workflow).
I would like to be able to run tests with various Python versions on the macos-13 runner, and therefore I need to use the actions/setup-python@v5 action. But that seems to be the source of the bug.

The following workflow crashes, still with the same Python error as previously:

name: tkinter minimal

on:
  workflow_dispatch:

jobs:
  minimal:
    runs-on: macos-13
    steps:
      - name: Install Python
        uses: actions/setup-python@v5
        with:
          python-version: "3.9"
      - name: import tkinter
        run: python3.9 -c "import tkinter"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/Users/runner/hostedtoolcache/Python/3.9.20/x64/lib/python3.9/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.9.20/x64/lib/python3.9/lib-dynload/_tkinter.cpython-39-darwin.so, 0x0002): Library not loaded: /usr/local/opt/tcl-tk/lib/libtcl8.6.dylib
  Referenced from: <0E547FD7-F776-378C-B4DE-8D241CDFE19E> /Users/runner/hostedtoolcache/Python/3.9.20/x64/lib/python3.9/lib-dynload/_tkinter.cpython-39-darwin.so
  Reason: tried: '/usr/local/opt/tcl-tk/lib/libtcl8.6.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/usr/local/opt/tcl-tk/lib/libtcl8.6.dylib' (no such file), '/usr/local/opt/tcl-tk/lib/libtcl8.6.dylib' (no such file), '/usr/local/lib/libtcl8.6.dylib' (no such file), '/usr/lib/libtcl8.6.dylib' (no such file, not in dyld cache)

Looks like I cannot open an issue in the setup-python action repo, is here still the right place to discuss this bug ?

@vaishalipawar1490
Copy link

Hi @WeisLeDocto
Could you please try the workaround below to see if it resolves the issue for you? This should allow you to test with different Python versions on the macOS 13 runner.
Please let us know if this helps !



name: tkinter minimal

on:
workflow_dispatch:

jobs:
build:
runs-on: macos-13
steps:
- name: Install Python
uses: actions/setup-python@v5
with:
python-version: “3.9”

  - name: Adding Symlink
    run: |
      ln -sf /usr/local/opt/tcl-tk@8 /usr/local/opt/tcl-tk

  - name: Import tkinter
    run: | 
      python3.9 -c "import tkinter; print(f'Tkinter imported successfully. Version: {tkinter.TkVersion}')"

@WeisLeDocto
Copy link
Author

The following workflow runs gracefully 👍

name: tkinter minimal

on:
  workflow_dispatch:

jobs:
  build:
    runs-on: macos-13
    steps:
      - name: Install Python
        uses: actions/setup-python@v5
        with:
          python-version: "3.9"
      - name: Adding Symlink
        run: ln -sf /usr/local/opt/tcl-tk@8 /usr/local/opt/tcl-tk
      - name: import tkinter
        run: python3.9 -c "import tkinter; print(f'Tkinter imported successfully. Version {tkinter.TkVersion}')"

Many thanks for your help !

Will the runner images be fixed to avoid having to symlink tcl-tk, or should I consider this the new normal ?

@vaishalipawar1490
Copy link

We're investigating this issue and working on a fix. We'll keep you informed as soon as it's resolved.

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

No branches or pull requests

4 participants