Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: pg_config executable not found. though using psycopg2-binary #699

Closed
allan-simon opened this issue Mar 29, 2018 · 10 comments
Closed
Labels

Comments

@allan-simon
Copy link

I have the following lines in my requirements.txt

psycopg2-binary

to avoid having to compile it, however when i run pip install I got the following error messages:

Downloading/unpacking psycopg2-binary (from -r requirements.txt (line 25))
  Running setup.py (path:/tmp/pip-build-1xk9772d/psycopg2-binary/setup.py) egg_info for package psycopg2-binary
    
    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
    <http://initd.org/psycopg/docs/install.html>).
    Complete output from command python setup.py egg_info:
    running egg_info
creating pip-egg-info/psycopg2_binary.egg-info
writing top-level names to pip-egg-info/psycopg2_binary.egg-info/top_level.txt
writing dependency_links to pip-egg-info/psycopg2_binary.egg-info/dependency_links.txt
writing pip-egg-info/psycopg2_binary.egg-info/PKG-INFO
writing manifest file 'pip-egg-info/psycopg2_binary.egg-info/SOURCES.txt'



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
<http://initd.org/psycopg/docs/install.html>).

----------------------------------------
Cleaning up...
Command python setup.py egg_info failed with error code 1 in /tmp/pip-build-1xk9772d/psycopg2-binary
@dvarrazzo
Copy link
Member

Probably you are using an old version of pip or a platform that doesn't support manylinux (e.g. Linux Alpine).

@allan-simon
Copy link
Author

i'm on debian jessie, I will check for the version of pip

@allan-simon
Copy link
Author

indeed, upgrading pip fix the issue, thanks

@kitten77
Copy link

I am having the same problem
pip 18.1
12.0-RELEASE FreeBSD 12.0-RELEASE r341666 GENERIC amd64
I solved this by doing a local install of
py36-psycopg2
and then
pip install psycopg2
Seems to have fix it for now

@hoylemd
Copy link

hoylemd commented Apr 29, 2019

I ran into a similar problem, trying to install psycopg2 into a python:3.7-alpine container. I'm sure something could be done in the Dockerfile to install pg_config properly first, but I just switched by made image to python:3.7-slim and it worked. In my case it wasn't terribly important to use alpine as the base, but if someone else finds this and does need to use alpine, look into that. (that might be what @kitten77 was referring to, but I didn't check)

@tony-zebra
Copy link

Like @hoylemd I ran into this on a python:3.7-alpine container. I fixed it by installing postgresql-dev in my Dockerfile via apk add postgresql-dev (with thanks to this stackoverflow answer).

@yk2kus
Copy link

yk2kus commented Aug 18, 2019

sudo apt-get install libpq-dev

https://tutorials.technology/solved_errors/9-Error-pg_config-executable-not-found.html

@HenrryVargas
Copy link

this is ok for me: sudo apt-get install libpq-dev

@allan-simon
Copy link
Author

this is ok for me: sudo apt-get install libpq-dev

however it should not, as the goal of psycopg-binary is to avoid compilation and installing these headers, if we are to install these , then using psycopg (without binary) is certainly an option.

@Georg-coder
Copy link

for me, none of the above solutions worked. I use python 3.6.1 and pycharm on Mac

@psycopg psycopg locked as resolved and limited conversation to collaborators Jan 30, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

8 participants