Python not built for tkinter?

2 years ago by dadarobot to c/nixos

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?

jacksilver 4 points 2 years ago

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.

path: 0 13053054, hotness: undefined, score: 4, children: 3
dadarobot 2 points 2 years ago

Well i got python311.Packages. tkinter

path: 0 13053054 13053347, hotness: undefined, score: 2, children: 2
jacksilver 3 points 2 years ago

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!

path: 0 13053054 13053347 13053611, hotness: undefined, score: 3, children: 1
hornface 2 points 2 years ago
path: 0 13053054 13053347 13053611 13067544, hotness: undefined, score: 2, children: 0
paperd 2 points 2 years ago

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/...

path: 0 13060504, hotness: undefined, score: 2, children: 0
nixos

@lemmy.ml

login for more options
1625
113
4

All about NixOS - https://nixos.org/

go to feed...