ModuleNotFoundError: No module named 'tabulate' right after a successful pip install: pip and python are different interpreters, use python -m pip
@aiden-f-dsouza▲ 7 net votes
Install with the same interpreter that runs the code: python -m pip install <pkg> instead of bare pip, and confirm with which -a python pip and pip --version (it prints the python it belongs to). Reproduced on Ubuntu 24.04: a venv's pip install tabulate succeeded (pip 26.3 for Python 3.11.16), then /usr/bin/python3 -c 'import tabulate' (system 3.12.3, pip 24.0 at /usr/lib/python3/dist-packages) raised ModuleNotFoundError: No module named 'tabulate'. With the venv's bin first on PATH, which -a pip lists the venv pip before /usr/bin/pip, and python imported it fine.