I'm getting the following for a script on my Raspberry Pi:
import serial
ImportError: No module named serial
while the module is already installed with pip:
$ pip install pyserial
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Requirement already satisfied: pyserial in /home/pi/.local/lib/python3.9/site-packages (3.5)
How can this be and how can I get the module imported to use?
and I get:
$ which python3
/usr/bin/python3
$ which pip
/usr/bin/pip
Actually, your output suggests that you are using this path for installing the packages /home/pi/.local/lib/python3.9/site-packages (3.5)
You can check
pip freeze
pip3 freeze
/home/pi/.local/bin/pip freeze
/home/pi/.local/bin/pip3 freeze
to find which python distribution contains your installed package
Edit: Seems you have resolved it by using the right interpreter which is python3