R
R
Ruslan2016-05-05 12:58:12
PostgreSQL
Ruslan, 2016-05-05 12:58:12

How to install psycopg2?

I have been trying to solve the problem for several days - it does not work.
Error logs:

Error: pg_config executable not found.

Collecting psycopg2==2.6.1
  Using cached psycopg2-2.6.1.tar.gz
    Complete output from command python setup.py egg_info:
    running egg_info
    creating pip-egg-info/psycopg2.egg-info
    writing pip-egg-info/psycopg2.egg-info/PKG-INFO
    writing dependency_links to pip-egg-info/psycopg2.egg-info/dependency_links.txt
    writing top-level names to pip-egg-info/psycopg2.egg-info/top_level.txt
    writing manifest file 'pip-egg-info/psycopg2.egg-info/SOURCES.txt'
    warning: manifest_maker: standard file '-c' not found
    
    Error: pg_config executable not found.
    
    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'.
    
    ----------------------------------------

Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/s5/gszz_sn97_q00sn6hnp0lmxh0000gn/T/pycharm-packaging/psycopg2/

UPD: solved with the help of the command
PATH=$PATH:/Applications/Postgres.app/Contents/Versions/9.5/bin/ sudo pip install psycopg2

Answer the question

In order to leave comments, you need to log in

4 answer(s)
M
mukizu, 2016-05-05
@Izmena

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 ...

It seems like they say in plain text - the correct path to the postgres should be added to PATH. Either in the specified way, or
sudo PATH=$PATH:/Applications/Postgres.app/Contents/Versions/9.3/bin
And then
pip install psycopg2

A
Alexey Sergeev, 2016-05-05
@SergeevAI

If the 3rd python, then
through the virtual environment
I did not notice that Mac :)
See here
initd.org/psycopg/docs/install.html
They suggest installing through Fink.
I remember that there was a similar problem, but I don’t remember how I solved it, it was a long time ago and I already have a driver installed on my Mac)

S
sim3x, 2016-05-05
@sim3x

Most often it is better to install postgres locally so that
If not, then you need to put

libpq-dev
Description: header files for libpq5 (PostgreSQL library)
Header files and static library for compiling C programs to link with the libpq library in
order to communicate with a PostgreSQL database backend.

sudo apt-get install libpq-dev python3-dev

D
domanskiy, 2021-08-02
@domanskiy

Windows.
There was the same problem.
Deleted the entire venv folder and reinstalled everything. Just started with psycopg2 then alchemy and other project packages

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question