-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Install tk-dev and tcl-dev before building python #127
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
Conversation
Two of the Travis jobs failed because of connection errors during the apt-get install... No actual issue with the build. |
LGTM cc @tianon |
A few size comparisons for posterity:
|
LGTM |
- `python`: `build tkinter module` (docker-library/python#127)
is there like some simple command to install tk? |
@brando90, it is already installed (that is what this and #130 fixed). You just need to get the display hooked into the container. $ docker run -it --rm python:3.6-alpine3.6 python -m tkinter
Traceback (most recent call last):
File "/usr/local/lib/python3.6/runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "/usr/local/lib/python3.6/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/usr/local/lib/python3.6/tkinter/__main__.py", line 7, in <module>
main()
File "/usr/local/lib/python3.6/tkinter/__init__.py", line 3982, in _test
root = Tk()
File "/usr/local/lib/python3.6/tkinter/__init__.py", line 2017, in __init__
self.tk = _tkinter.create(screenName, baseName, className, interactive, wantobjects, useTk, sync, use)
_tkinter.TclError: no display name and no $DISPLAY environment variable
$ docker run -it --rm -e DISPLAY python:3.6-alpine3.6 python -m tkinter
Traceback (most recent call last):
File "/usr/local/lib/python3.6/runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "/usr/local/lib/python3.6/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/usr/local/lib/python3.6/tkinter/__main__.py", line 7, in <module>
main()
File "/usr/local/lib/python3.6/tkinter/__init__.py", line 3982, in _test
root = Tk()
File "/usr/local/lib/python3.6/tkinter/__init__.py", line 2017, in __init__
self.tk = _tkinter.create(screenName, baseName, className, interactive, wantobjects, useTk, sync, use)
_tkinter.TclError: couldn't connect to display ":0.0" |
|
@platonfloria, you need to reinstall the $ docker run -i --rm python:3.7.4-alpine sh - <<EOF
apk add -U tk
python -m tkinter
EOF
fetch http://dl-cdn.alpinelinux.org/alpine/v3.10/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.10/community/x86_64/APKINDEX.tar.gz
(1/12) Installing libxau (1.0.9-r0)
(2/12) Installing libbsd (0.9.1-r0)
(3/12) Installing libxdmcp (1.1.3-r0)
(4/12) Installing libxcb (1.13.1-r0)
(5/12) Installing libx11 (1.6.8-r1)
(6/12) Installing libxrender (0.9.10-r3)
(7/12) Installing libpng (1.6.37-r1)
(8/12) Installing freetype (2.10.0-r0)
(9/12) Installing fontconfig (2.13.1-r0)
(10/12) Installing libxft (2.3.3-r0)
(11/12) Installing tcl (8.6.9-r0)
(12/12) Installing tk (8.6.9-r0)
Executing busybox-1.30.1-r2.trigger
OK: 34 MiB in 47 packages
Traceback (most recent call last):
File "/usr/local/lib/python3.7/runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "/usr/local/lib/python3.7/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/usr/local/lib/python3.7/tkinter/__main__.py", line 7, in <module>
main()
File "/usr/local/lib/python3.7/tkinter/__init__.py", line 3988, in _test
root = Tk()
File "/usr/local/lib/python3.7/tkinter/__init__.py", line 2023, in __init__
self.tk = _tkinter.create(screenName, baseName, className, interactive, wantobjects, useTk, sync, use)
_tkinter.TclError: no display name and no $DISPLAY environment variable The tk package is uninstalled after python is compiled in the docker image to save space, since it is uncommon for image users to need tk. |
@jstewmon and/or @platonfloria Have you tried actually setting up DISPLAY etc. to run it? My following run was not successful.
Here, there should be a demo tkinter window popping up. But it did not. And I got this error.
FWIW, if I use |
@rayluo, sorry but I never directly used tkinter - I needed support for it to create a build environment for PyInstaller, which imported tkinter. |
@jstewmon , interesting. I wonder how your "build environment for PyInstaller" would manage to work. It might pass the build procedure while the tkinter package was technically available, but could your PyInstaller actually fire up a GUI? Regardless, is the current failing to launch a tkinter gui from UPDATE: Never mind. Happened to find a workaround. Adding a |
$ docker run --rm -it -e DISPLAY=$DISPLAY python:3-alpine sh -c 'apk add --no-cache tk && python -m tkinter'
Unable to find image 'python:3-alpine' locally
3-alpine: Pulling from library/python
801bfaa63ef2: Already exists
8723b2b92bec: Pull complete
4e07029ccd64: Pull complete
594990504179: Pull complete
140d7fec7322: Pull complete
Digest: sha256:7492c1f615e3651629bd6c61777e9660caa3819cf3561a47d1d526dfeee02cf6
Status: Downloaded newer image for python:3-alpine
fetch http://dl-cdn.alpinelinux.org/alpine/v3.12/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.12/community/x86_64/APKINDEX.tar.gz
(1/13) Installing libxau (1.0.9-r0)
(2/13) Installing libbsd (0.10.0-r0)
(3/13) Installing libxdmcp (1.1.3-r0)
(4/13) Installing libxcb (1.14-r1)
(5/13) Installing libx11 (1.6.12-r0)
(6/13) Installing libxrender (0.9.10-r3)
(7/13) Installing brotli-libs (1.0.9-r1)
(8/13) Installing libpng (1.6.37-r1)
(9/13) Installing freetype (2.10.4-r0)
(10/13) Installing fontconfig (2.13.1-r2)
(11/13) Installing libxft (2.3.3-r0)
(12/13) Installing tcl (8.6.10-r0)
(13/13) Installing tk (8.6.10-r1)
Executing busybox-1.31.1-r19.trigger
OK: 32 MiB in 49 packages
Traceback (most recent call last):
File "/usr/local/lib/python3.9/runpy.py", line 197, in _run_module_as_main
return _run_code(code, main_globals, None,
File "/usr/local/lib/python3.9/runpy.py", line 87, in _run_code
exec(code, run_globals)
File "/usr/local/lib/python3.9/tkinter/__main__.py", line 7, in <module>
main()
File "/usr/local/lib/python3.9/tkinter/__init__.py", line 4553, in _test
root = Tk()
File "/usr/local/lib/python3.9/tkinter/__init__.py", line 2262, in __init__
self.tk = _tkinter.create(screenName, baseName, className, interactive, wantobjects, useTk, sync, use)
_tkinter.TclError: couldn't connect to display ":0" You probably need the X11 socket: https://stackoverflow.com/a/50338944 and an Since GitHub isn't really a help forum, it'd be better to post future questions like this in the Docker Community Forums, the Docker Community Slack, or Stack Overflow. |
@yosifkit , thanks for chiming in! Actually, I've pasted my command line in each of my recent posts here. The use of That being said, now I already figured it out (after reading a dozen stackoverflow posts), and left a solution in my previous message. Paste it again here, for future readers. The following line works for me.
|
Fixes #122