Python not built for tkinter?

I have a program that I wrote, maybe I didn't package it appropriately, but I cannot got it to run. I wrote it on a manjaro install, and tested it on another manjaro install, both were fine. I packaged it with poetry and copied the wheel over.

Today I tried to install it on my nixos surface tablet I use at work. I get this error on installation:

Traceback (most recent call last):                                            File "/home/gzuh/.local/bin/willcallgui", line 5, in <module>
    from willcallgui import willcallgui
  File "/home/gzuh/.local/share/pipx/venvs/willcallgui/lib/python3.11/site-packages/willcallgui/willcallgui.py", line 12, in <module>
    import tkinter as tk
  File "/nix/store/h723hb9m43lybmvfxkk6n7j4v664qy7b-python3-3.11.9/lib/python3.11/tkinter/__init__.py", line 38, in <module>
    import _tkinter # If this fails your Python may not be configured for Tk
    ^^^^^^^^^^^^^^^
ModuleNotFoundError: No module named '_tkinter'

These are the packages i have installed... I'm trying to install it with pipx...

environment.systemPackages = with pkgs; [
    vim
    wget
    screen
    google-chrome
    openssh
    blackbox-terminal
    tailscale
    gnome.gnome-tweaks
    imagemagick
    git
    python311Full
    python311Packages.tkinter
    python311Packages.pip
    python311Packages.pipx

  ];

What am i missing?

9 points · 4 comments · view on lemmy.world

4 Comments

jacksilver@lemmy.world · 4 pts · 1y (3 replies)

Not 100% sure becuase I don't know you're full environment, but tkinter sometimes requires an additional OS level install. I know Ubuntu requires something like "sudo apt install python3.10-tk".

Not familiar with NixOS, but saw somethings mentioning "nix-env -i python3-tkinter", but no idea if that's a real command.

dadarobot@lemmy.sdf.org · 2 pts · 1y (2 replies)

Well i got python311.Packages. tkinter

jacksilver@lemmy.world · 3 pts · 1y (1 reply)

Sorry I missed that in the code block. I tried to dive a bit deeper, but it looks like there are different ways to build a python env in NixOS and the issues you're running into could depend on your build process.

Found this documentation, but it's a bit dense for me given my lack of experience with NixOS.

Best of luck though!

hornface@fedia.io · 2 pts · 1y
[ removed ]
paperd@lemmy.zip · 2 pts · 1y

So you just tried to install the packages in your system then use pipx? I don't think that's going to work.

You probably want a devshell, you can use a flake like this: https://github.com/NixOS/templates/tree/master/python