You need to use the
--user flag when you install stuff using Pip on Ubuntu and Debian without a virtualenv, otherwise you get the above error. So
pip install --user keepkey
But aside from that, this will only help if you Electrum is downloaded as a python package and not as an appimage or anything packaged like that. I assume that's how you installed it though, so I think you should open your file manager, look for the folder where you downloaded and unzipped Electrum to (if you didn't unzip it, you should do so now), and locate the file
contrib/requirements/requirements-hw.txt. And install everything in it just to be on the safe side:
hidapi
# device plugin: trezor
trezor[hidapi]>=0.13.0,<0.14
# device plugin: safe_t
safet>=0.1.5
# device plugin: keepkey
keepkey>=6.3.1
# device plugin: ledger
# note: btchip-python only needed for "legacy" protocol and HW.1 support
# note: ledger-bitcoin==0.2.2 added new deps we don't want to bundle. otherwise it should be ok to use.
# see https://github.com/LedgerHQ/app-bitcoin-new/issues/192
btchip-python>=0.1.32
ledger-bitcoin>=0.2.0,<0.2.2
hidapi
# device plugin: coldcard
ckcc-protocol>=0.7.7
# device plugin: bitbox02
bitbox02>=6.2.0
# device plugin: jade
cbor>=1.0.0,<2.0.0
pyserial>=3.5.0,<4.0.0
# prefer older protobuf (see #7922)
# (pulled in via e.g. keepkey and bitbox02)
protobuf>=3.20,<4
# prefer older colorama to avoid needing hatchling
# (pulled in via trezor -> click -> colorama)
# (pulled in via safet -> click -> colorama)
colorama<0.4.6