This is why you should use Electrum in a .venv, or at least make sure you're not installing other package that conflict with Electrum's dependencies. You can prevent a lot of other weird errors from happening that way.
IMO pipx is better choice since OP wants to run program, rather than software development.
You can globally install an application by running
pipx install PACKAGE
This automatically creates a virtual environment, installs the package, and adds the package's associated applications (entry points) to a location on your
PATH. For example,
pipx install pycowsay makes the
pycowsay command available globally, but sandboxes the pycowsay package in its own virtual environment.
pipx never needs to run as sudo to do this.For OP's usage, this command should work (tested on my Debian 12 VM).
$ sudo apt install pipx
$ pipx ensurepath
$ pipx install git+https://github.com/spesmilo/electrum.git@4.5.8
$ which electrum
/home/user/.local/bin/electrum