Skip to content

tkinter doesn't work on slim-buster Python images  #484

Description

@Tiksagol

tkinter doesn't work on slim-buster images -

>> docker run --rm -ti python:3.8-slim-buster python -c "**import tkinter**"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/usr/local/lib/python3.8/tkinter/__init__.py", line 36, in <module>
    import _tkinter # If this fails your Python may not be configured for Tk
**ImportError: libtk8.6.so: cannot open shared object file: No such file or directory**

Activity

  1. yosifkit commented on May 14, 2020

    @yosifkit
    Member

    In order to keep the slim images actually slim the library is not kept on purpose. See #122 (comment).

    && find /usr/local -type f -executable -not \( -name '*tkinter*' \) -exec ldd '{}' ';' \
    | awk '/=>/ { print $(NF-1) }' \
    | sort -u \
    | xargs -r dpkg-query --search \
    | cut -d: -f1 \
    | sort -u \
    | xargs -r apt-mark manual \
    && apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false \

    You should be able to just install the tk package from apt, but it has quite a few dependencies:

    docker run -it --rm python:3.8-slim-buster bash
    root@419462f4cf20:/# apt-get update
    Get:1 http://deb.debian.org/debian buster InRelease [121 kB]
    Get:2 http://security.debian.org/debian-security buster/updates InRelease [65.4 kB]
    Get:3 http://deb.debian.org/debian buster-updates InRelease [49.3 kB]
    Get:4 http://security.debian.org/debian-security buster/updates/main amd64 Packages [198 kB]
    Get:5 http://deb.debian.org/debian buster/main amd64 Packages [7905 kB]
    Get:6 http://deb.debian.org/debian buster-updates/main amd64 Packages [7380 B]
    Fetched 8347 kB in 1s (8615 kB/s)                         
    Reading package lists... Done
    root@419462f4cf20:/# apt-get install tk
    Reading package lists... Done
    Building dependency tree       
    Reading state information... Done
    The following additional packages will be installed:
      fontconfig-config fonts-dejavu-core libbsd0 libdrm-amdgpu1 libdrm-common libdrm-intel1
      libdrm-nouveau2 libdrm-radeon1 libdrm2 libedit2 libelf1 libfontconfig1 libfontenc1
      libfreetype6 libgl1 libgl1-mesa-dri libglapi-mesa libglvnd0 libglx-mesa0 libglx0
      libice6 libllvm7 libpciaccess0 libpng16-16 libsensors-config libsensors5 libsm6
      libtcl8.6 libtk8.6 libutempter0 libx11-6 libx11-data libx11-xcb1 libxau6 libxaw7
      libxcb-dri2-0 libxcb-dri3-0 libxcb-glx0 libxcb-present0 libxcb-shape0 libxcb-sync1
      libxcb1 libxcomposite1 libxdamage1 libxdmcp6 libxext6 libxfixes3 libxft2 libxi6
      libxinerama1 libxmu6 libxmuu1 libxpm4 libxrandr2 libxrender1 libxshmfence1 libxss1
      libxt6 libxtst6 libxv1 libxxf86dga1 libxxf86vm1 lsb-base sensible-utils tcl tcl8.6
      tk8.6 ucf x11-common x11-utils xbitmaps xterm
    Suggested packages:
      pciutils lm-sensors tcl-tclreadline mesa-utils xfonts-cyrillic
    The following NEW packages will be installed:
      fontconfig-config fonts-dejavu-core libbsd0 libdrm-amdgpu1 libdrm-common libdrm-intel1
      libdrm-nouveau2 libdrm-radeon1 libdrm2 libedit2 libelf1 libfontconfig1 libfontenc1
      libfreetype6 libgl1 libgl1-mesa-dri libglapi-mesa libglvnd0 libglx-mesa0 libglx0
      libice6 libllvm7 libpciaccess0 libpng16-16 libsensors-config libsensors5 libsm6
      libtcl8.6 libtk8.6 libutempter0 libx11-6 libx11-data libx11-xcb1 libxau6 libxaw7
      libxcb-dri2-0 libxcb-dri3-0 libxcb-glx0 libxcb-present0 libxcb-shape0 libxcb-sync1
      libxcb1 libxcomposite1 libxdamage1 libxdmcp6 libxext6 libxfixes3 libxft2 libxi6
      libxinerama1 libxmu6 libxmuu1 libxpm4 libxrandr2 libxrender1 libxshmfence1 libxss1
      libxt6 libxtst6 libxv1 libxxf86dga1 libxxf86vm1 lsb-base sensible-utils tcl tcl8.6 tk
      tk8.6 ucf x11-common x11-utils xbitmaps xterm
    0 upgraded, 73 newly installed, 0 to remove and 6 not upgraded.
    Need to get 29.7 MB of archives.
    After this operation, 238 MB of additional disk space will be used.
    Do you want to continue? [Y/n] ^C
  2. added
    questionUsability question, not directly related to an error with the image
    on May 15, 2020
  3. YuyaR commented on Oct 1, 2021

    @YuyaR

    @yosifkit Did you successfully build the image though? Because after the 'Do you want to continue? [Y/n]' mine just aborted. I am not sure how to circumvent the prompt.

  4. tianon commented on Oct 1, 2021

    @tianon
    Member

    Add -y to the apt-get install command.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionUsability question, not directly related to an error with the image

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions