How to run python on nixos

this is a game written in python pyqt5 ,
also there is venv inside the project but the issue is weather i use venv or not it says

    import tkinter as tk
  File "/nix/store/vagb0sjv83ybi435i6iiv10hjrdghph9-python3-3.10.12/lib/python3.10/tkinter/__init__.py", line 37, in <module>
    import _tkinter # If this fails your Python may not be configured for Tk
ModuleNotFoundError: No module named '_tkinter'
pip3 install tkinter
ERROR: Could not find a version that satisfies the requirement tkinter (from versions: none)
ERROR: No matching distribution found for tkinter
1 Like

Does that mean there is no way to use python normally ?

            
Traceback (most recent call last):
  File "/home/krafi/inviOSU/run.py", line 10, in <module>
    from PyQt5.QtMultimedia import QMediaPlayer, QMediaContent
ModuleNotFoundError: No module named 'PyQt5.QtMultimedia'

now how can i find PyQt5.QtMultimedia . it should install with pip3 install pyqt5

It is not possible to use pip to imperatively install global python packages, that is correct. Please refer to the manual section linked above for the intended ways to build a development environment with python packages.

Note that committing a virtual environment to source control is very much an antipattern, by the way, and I’d expect it not to work across different machines (and certainly it will fail across operating systems and architectures). Observe, for example, that the python executable within the venv is only a symlink to /usr/bin/python3, leaving you at the mercy of the system Python. Pip has attempted to guarantee on the original machine that the package versions are compatible with the system Python on that machine, and it may e.g. have built native libraries which work on the original machine, but there are no such guarantees once you copy that venv bit-for-bit onto a new machine.

The easiest way to reproduce a virtual environment is to run pip freeze within the venv on the machine where you created that venv, write its output into a requirements.txt file which you commit to source control, and then python -m venv inviOSU_env and inviOSU_env/bin/python -m pip install -r requirements.txt on the machine where you want to use the virtual environment. (There are dozens of ways to manage Python dependencies, with various upsides and downsides, of which I have listed probably the simplest. Committing the contents of a virtual environment will in general just not work except under very fragile conditions.)