Skip to main content
  1. Note/

Resolve `psycopg2` Install Error on MacOS

·1 min· ·
Blog En Python
Liu Zhe You
Author
Liu Zhe You
Skilled in full-stack development and DevOps, currently focusing on Backend.
The cover is from the official psycopg documentation.

Common Issues When Installing psycopg2 on MacOS
#

brew install libpq --build-from-source
brew install openssl

Add the following environment variables to your dotfiles or ~/.zshrc (depending on the shell you are using):

export LDFLAGS="-L$(brew --prefix openssl)/lib"
export CPPFLAGS="-I$(brew --prefix openssl)/include"
export PKG_CONFIG_PATH="$(brew --prefix openssl)/lib/pkgconfig"

Then, you should be able to install psycopg2:

pip install psycopg2

Related

How to use Transaction in SqlAlchemy
·2 mins
Blog En SqlAlchemy Backend Python
How to transaction in SqlAlchemy
Python: Read File(BinaryIO) Multiple Time
·1 min
Blog En Python
Read file (BinaryIO) multiple time in Python. Solution to prevent empty content in the second read.
PGMQ(PostgreSQL Message Queue) Setup
·2 mins
Blog En Backend Postgresql
PGMQ is a lightweight message queue. Like AWS SQS and RSMQ but on Postgres. The article is about how to setup PGMQ with Docker Compose to connect with official Python client
Hugo Functions: Get Slice From Specific Range
·2 mins
Blog En Hugo
How to get a slice from a specific range in Hugo?
Redis Persistence: RDB and AOF
·5 mins
Blog En Database Redis
Detailed explanation of Redis persistence settings: RDB and AOF. Pros and cons of RDB and AOF. Detailed implementation with Redis source code.
PgBouncer: Lightweight Postgres Connection Pool
·2 mins
Blog Database En Postgresql
Solving Django backend DB connection overload with PgBouncer