Showing posts with label psycopg2. Show all posts
Showing posts with label psycopg2. Show all posts

Nov 6, 2016

How to install psycopg2 under virtualenv

Psycopg is the most popular PostgreSQL adapter for Python. I prefer PostgreSQL to MySQL. Django projects usually integrate with PostgreSQL. Firstly we need to install 2 packages: libpq-dev and python-dev for Debian/Ubuntu.
Use
sudo apt install libpq-dev python3-dev
or
sudo apt install libpq-dev python-dev
depends on Python version you want.
Now install psycopg2 to integrate to our Django projects.
pip install psycopg2
Ensure to activate the virtual environment before installing psycopg2:
source {$your-env-dir}/bin/activate