Repository navigation
python is not configured for tkinter #122
Description
Activity
- added 2 commits that reference this issue
on Jun 30, 2016 @tianon @yosifkit any thoughts on this? I can submit a PR if there's no objection to adding tk to the official images. I think the -dev package is required for the build, and the lib is required for the runtime.
My plan to fix would be to install tk and tk-dev from the apt/apk, removing tk-dev after the building python.
99% of Docker files shouldn't need the Tkinter files, as Docker isn't designed to handle GUIs (I believe, correct me if I'm wrong).
You should be able to install Tkinter in a separate Dockerfile that extends the Python ones provided here.
FROM python:3.5 RUN apt-get update && apt-get install tk-dev && rm -r /var/lib/apt/lists/*Reacted by Lei Chen@kevin-brown the tkinter module is defined CPython and is complied into python.
https://wiki.python.org/moin/TkInter
I'm not aware of any other way to build/install it as an
so.Since this must be complied into python and cannot be added later, I propose a possible solution to emphasize the "include everything" default tag vs the tiny
slimandalpinetags:- Install
tk-dev tk tcl-dev tclduring install so thattkinteris compiled in to python.- remove
tk-dev tcl-devin the non-slim and non-alpine variants - remove
tk-dev tk tcl-dev tclin slim and alpine to save space-
users of these two varints that want to use tkinter can
apt-get update && apt-get install tk tcl(or appropriate alpineapk add) -
I tested this on the
2.7-slimimage and it worked fine$ docker run --rm -it python:2.7-slim python -m Tkinter ... ImportError: libtk8.6.so: cannot open shared object file: No such file or directory $ docker run --rm -it python:2.7-slim bash -c 'apt-get update && apt-get install -y tcl tk && python -m Tkinter' ... _tkinter.TclError: no display name and no $DISPLAY environment variable
-
- remove
Size differences:
# current python 2.7.12-slim 840fa73abd8a 7 days ago 184.1 MB python 2.7.12 774abfa592f5 7 days ago 665.2 MB # new python 2.7-slim 29cb1e9fce53 3 seconds ago 186.1 MB python 2.7 9b682a8110bf 38 minutes ago 673 MB- Install
- SGTM!
so whats the solution? How do we get the library we need?
whats wrong with
apt install python3-tkwhats wrong with
apt install python3-tkWe don't use the Debian/apt-provided python, but compile and install it from upstream source directly. The
python3-tkpackage is built for the Debian python3 (which may or may not be the same version of python as the one built in the image) and also would pull in python3 from Debian and you would end up with two versions of python3 in the image.@yosifkit how do I do that?
@brando90, it is already installed: #127 (comment). If you need help getting it to connect to your display, it'd be better to post questions like that in the Docker Community Forums, the Docker Community Slack, or Stack Overflow.
Is tkinter purposefully omitted? It seems like the only way to enable it is to rebuild from source.
Adding
apt-get update && apt-get install -y --no-install-recommends tk-dev && rm -r /var/lib/apt/lists/*to the current Dockerfiles appears to resolve the issue, but adds ~20MB to the resulting image.Current behavior: