45
I installed a package with pip but Python says "ModuleNotFoundError: No module named". I've tried reinstalling but it still doesn't work.
Loading...
Q&A · Answered
I installed a package with pip but Python says "ModuleNotFoundError: No module named". I've tried reinstalling but it still doesn't work.
Accepted answer
This is a common issue usually related to Python environments. Here are the solutions:
# Check Python path
which python
which python3
# Check pip path
which pip
which pip3
# Use python -m pip to ensure correct pip
python3 -m pip install package-name
# Or specify full path
/usr/bin/python3 -m pip install package-name
# Create and use virtual environment
python3 -m venv venv
source venv/bin/activate
pip install package-nameSay what you tried, not only what worked — the next person needs the reasoning. Code goes in a fenced block.