How to install Tk and Tkinter gitpod

How do I install python-tk and Tkinter, in Gitpod? Using “pip3 install tkinter” does nothing, and I dont even know if python-tk is installed. Someone please help.

Hi @Seba244c , I had to do that previously, and it seems you have to install tkinter before pyenv for it to work, i.e. in Gitpod’s core image.

Here is the Pull Request I made originally: https://github.com/gitpod-io/workspace-images/pull/119/files

I closed it without merging it because I wasn’t sure others would find it useful, but given that you’d like to have it, I’ll revive and merge that PR.

I’ll let you know when this ships in Gitpod.

Update: I’ve revived my old PR here: https://github.com/gitpod-io/workspace-images/pull/146

However, there are a few concerns around pulling libx11 into our gitpod/workspace-full base image, in particular on the image size impact.

Hi @Seba244c, do you still need Tk and Tkinter in Gitpod?

If so, I’d be happy to set up and host an official gitpod/workspace-python-tk Docker image. I think that would be the best way to go.

1 Like

Can I ask the status of gitpod/workspace-python-tk docker image ? Also, the tkinter is included with the python installation right ?

Hi @Kogam22, welcome to the Gitpod community! :tada:

I was basically waiting for someone to ask for it (in order not to make an image that isn’t useful). If you need it I’m happy to make it! :slight_smile:

Yes, that will be the case.

1 Like

I would like to have access to a gitpod workspace image with python-tk, because I couldn’t setup by myself (asked at stackexchange.com.
thanks!

1 Like

That problem occurs because the workspace-full-vnc image uses pyenv and the module path is different (source). To use python modules, you need to install them using python -m pip install ... .

Hi @makayabou, thanks for reaching out!

I went ahead and opened this Pull Request: https://github.com/gitpod-io/workspace-images/pull/303

Once the CI passes and this PR gets merged, it will publish two new official Docker images:

  • gitpod/workspace-python-tk (with tk-dev installed before pyenv so that they actually work together)

  • gitpod/workspace-python-tk-vnc (with a graphical virtual desktop on top)

It still needs a bit of work though (our custom Docker build tool, Dazzle, doesn’t currently support ARG instructions, which are used and needed in my PR).

Meanwhile, please subscribe to that Pull Request to get updates on the new official images, or feel free to fork our workspace-full image and add sudo apt-get install -q tk-dev somewhere before Pyenv is installed.