I want to use postgresql with my Django project, and for that I need to install psycopg2 in my virtualenv. I already have Postgresql 12.2 installed. However, when I run pip install psycopg2
, I get the following error:
Error: pg_config executable not found.
pg_config is required to build psycopg2 from source. Please add the directory
containing pg_config to the $PATH or specify the full executable path with the
option:
python setup.py build_ext --pg-config /path/to/pg_config build ...
or with the pg_config option in 'setup.cfg'.
If you prefer to avoid building psycopg2 from source, please install the PyPI
'psycopg2-binary' package instead.
For further information please check the 'doc/src/install.rst' file (also at
<https://www.psycopg.org/docs/install.html>).
I already found the pg_config executable at /Library/PostgreSQL/12/bin/pg_config
, but when I try to add it to the PATH variable using PATH="/Library/PostgreSQL/12/bin/pg_config:$PATH"
, no success or error message is shown. I have never used the PATH variable before, so I am not sure if I am doing this correctly. When I then try to run which pg_config
, it still says "pg_config not found", and when I try to install psycopg2 again, it shows the same error message.
Can anyone help me to solve this problem?