ImportError: No module named psycopg2 code example
Example 1: no module psycopg2
# For quick install
pip install psycopg2-binary
# For production-ready install
pip install psycopg2
# But it will fail if build prerequesties are not met:
# https://www.psycopg.org/docs/install.html#build-prerequisites
Example 2: ModuleNotFoundError: No module named 'psycopg2'
pip install psycopg2
Example 3: No module named 'psycopg2'
pip install psycopg2
Example 4: No module named 'psycopg2'
$ pip install psycopg2
# or
$ pipenv install psycopg2
Example 5: ModuleNotFoundError: No module named 'psycopg2'
pip install psycopg2-binary