But now I’m getting a new error when running a python script:
Reading inline script metadata from `/home/guttermonk/.local/share/whispernow/transcribe_gui.py`
warning: The requested interpreter resolved to Python 3.12.8, which is incompatible with the script's Python requirement: `==3.12`
Traceback (most recent call last):
File "/home/guttermonk/.local/share/whispernow/transcribe_gui.py", line 13, in <module>
import tkinter as tk
File "/nix/store/chkqz1vrr3dhqzld9r8iv014i1anb0y4-python/lib/python3.12/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'
To no avail, I tried adding the tkinter package using:
Adding libraries to environment.systemPackages pretty much never works.
Seems like using python312.withPackages (ps: [ ps.tkinter ]) in place of python312 should work?
$ nix-shell -p python3 --run 'python3 -c "import tkinter"'
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/nix/store/dzi9r3xn0ny4l4gwnyqpncljq40pdk6f-python3-3.12.8/lib/python3.12/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'
$ nix-shell -p 'python3.withPackages (ps: [ ps.tkinter ])' --run 'python3 -c "import tkinter"'
$ echo $?
0
Thanks so much for the suggestion. I updated this line in my overlay as follows (and thought for sure it was going to work), but am still getting the same error. src = super.python312.withPackages(ps: with ps; [ tkinter ]);
I’m inexperienced with python and wondering if the “warning” part of the error would cause the script to fail completely or if it’ll still run. warning: The requested interpreter resolved to Python 3.12.8, which is incompatible with the script's Python requirement: ==3.12
So the overlay is adding tkinter but the program isn’t finding it?
I wonder if the “underscore tkinter” in the error message (shown below) could hint towards a typo/bug in the WhisperNow program? ModuleNotFoundError: No module named '_tkinter'
@justinas I marked your answer as the solution since it answers the original question. Thanks so much for the info. I really learned a lot here.
I also just figured out that when I add the “withPackages” to the src line of the overlay, it breaks the part in the installPhase where it sets the LD_LIBRARY_PATH.
You can test it by adding the “withPackages” suggested above and running whispernow in terminal, which should throw this libz.so.1 error. Then comment the withPackages out, and the error goes away.