Installing psycopg2

Installing most Python libraries requires you to open your console and type:

pip install psycopg2

If that doesn't work, and you are using an Anaconda Python distribution, you can run the conda command, using:

conda install -c anaconda psycopg2

While most Python libraries can be downloaded and installed using:

python setup.py install

Since psycopg2 is more advanced than that and requires you to have a C compiler, Python header files, libpq header files, and the pg_config program. If you need to install psycopg2 from the source, the link to the instructions is in the following hint box.

To install psycopg2 from the source, the instructions are located at: http://initd.org/psycopg/docs/install.html#install-from-source

Get Mastering Geospatial Analysis with Python now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.