this post was submitted on 24 Oct 2024
10 points (91.7% liked)

nixos

1262 readers
3 users here now

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

founded 4 years ago
10
submitted 2 weeks ago* (last edited 2 weeks ago) by dadarobot@lemmy.sdf.org to c/nixos@lemmy.ml
 

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?

you are viewing a single comment's thread
view the rest of the comments
[–] jacksilver@lemmy.world 4 points 2 weeks ago (1 children)

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 points 2 weeks ago (1 children)

Well i got python311.Packages. tkinter

[–] jacksilver@lemmy.world 3 points 2 weeks ago (1 children)

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 points 2 weeks ago

This documentation is the right place to look - specifically, I think you need to use python.withPackages rather than trying to pull in each package as a separate item