How to install tkinter

Hello,
I am using PyCharm Community Edition to play with Python. I tried to create a GUI-based project using tkinter but I constantly encounter a “module not found” error for tkinter. I cannot install it separately and, from what I read, this is a Flatpak thing - the applications cannot access anything out of their sandbox. Is there a way to use tkinter in Endless OS right now?

Yes there is a way. I’ve created a Flatpak for Python 3.7 which includes TkInter. Instructions:

git clone https://github.com/egrath/Flatpaks.git
cd Flatpaks/idle37
./build.sh
flatpak install --user org.python.idle37_x86-64.flatpak

Thanks, IDLE works as expected :slight_smile: Is there a chance to have the whole installation as an updateable flatpak in the App Center?

No, it’s Python 3.7.3 by purpose, as this is the version installed with the current Endless OS release. If you can live with 3.7.3, but only need some additional Modules, you can run pip3 inside the Flatpak to install additional ones:

flatpak run --command=sh org.python.idle37

Now you are inside the Flatpak’s Sandbox. Use pip3 as usual. Please not that due to missing build tools (G++, …) you can only install Python modules which come precompiled. If you want a “more complete” environment, take a look at Podman, which allows you to use a complete installation of another Distribution like Ubuntu inside Endless OS.

You could ask to have tkinter included with the pycharm flatpak. See https://github.com/flathub/com.jetbrains.PyCharm-Community/issues/15. However, it seems that pycharm is just using the python from the freedesktop flatpak runtime, so https://gitlab.com/freedesktop-sdk/freedesktop-sdk/-/issues/976 may be what you really need.