Cause 1 of 5
The package is installed for a different interpreter than the one running.
Install into the exact interpreter that runs your code: python -m pip install requests. The python -m pip form binds pip to that Python; a bare pip on PATH may belong to another installation entirely.
Cause 2 of 5
You are outside the virtual environment.
Activate it first — source .venv/bin/activate, or .venv\Scripts\activate on Windows — then install. In VS Code, also select the venv interpreter in the status bar, because the Run button and the integrated terminal can otherwise use two different Pythons.
Cause 3 of 5
The install name differs from the import name.
pip install beautifulsoup4 imports as bs4, pip install pillow imports as PIL, pip install opencv-python imports as cv2, pip install python-dateutil imports as dateutil. Check the project's README for the import name rather than guessing from the package name.
Cause 4 of 5
Your own module is not on sys.path.
Running python subdir/script.py puts subdir/ on the path, not the project root, so sibling packages become invisible. Run it as a module from the root instead — python -m package.script — or install the project in editable mode with pip install -e ..
Cause 5 of 5
In Docker, the install layer was cached with an older requirements file.
Rebuild that layer: docker compose build --no-cache <service>. Copying requirements.txt before the rest of the source is the ordering that makes the cache invalidate correctly when dependencies change.