ModuleNotFoundError after installing

pip installed into a different Python than the one running the script

why

A system can easily have several Pythons — system, conda, venv, plus whatever the workflow or notebook uses. pip install X installs into whichever pip is first on PATH, which is often not the interpreter that then runs your code.

what to do

Tie them together: python -m pip install X uses the same interpreter you are running. To confirm, print sys.executable from inside the failing script — that is the Python that matters, and it is frequently a surprise.

Python environment behaviour
This is one entry from BioErrors, a catalogue of bioinformatics error messages that point at the wrong thing. Every entry was traced to its real cause before it was written down.
If your error is not in it, paste it there and it gets traced and added.