Skip to content

Instantly share code, notes, and snippets.

@rutcreate
Last active August 26, 2024 11:57
Show Gist options
  • Save rutcreate/a0101339923f4501d36b7716afb6dc05 to your computer and use it in GitHub Desktop.
Save rutcreate/a0101339923f4501d36b7716afb6dc05 to your computer and use it in GitHub Desktop.
Install psycopg2 on Ubuntu 20.04

Install packages

sudo apt install build-essensial libpq-dev postgresql postgresql-contrib python3-venv python3-dev

Test

Create virtual env

mkdir /tmp/testpsycopg2
cd /tmp/testpsycopg2
python3 -m venv venv
source venv/bin/activate

Install psycopg2

pip install psycopg2

Troubleshooting

error: invalid command 'bdist_wheel'

pip install wheel

fatal error: libpq-fe.h: No such file or directory

sudo apt install libpq-dev

fatal error: Python.h: No such file or directory

sudo apt install python3-dev

gcc: error: x86_64-linux-gnu-gcc: No such file or directory

sudo apt install build-essential
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment