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

Psycopg2 2.9.1 Python Binary no longer installs #1325

Closed
CoburnJoe opened this issue Jul 9, 2021 · 14 comments
Closed

Psycopg2 2.9.1 Python Binary no longer installs #1325

CoburnJoe opened this issue Jul 9, 2021 · 14 comments

Comments

@CoburnJoe
Copy link

Hi, I'm using psycopg2-binary in Python, and it is not a working build.

Reverting to 2.8.6 still works. Installing in Docker with Python 3.8 presents this 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.

Note the If you prefer to avoid building psycopg2 from source, please install the PyPI
'psycopg2-binary' package instead.
This states this even when attempting to install the binary package.

I've attempted to compile from source by installing various postgres tools such as postgresql-libs, postgresql-devel libpq, and libpq-devel, but the fact remains, I have to install from source, and cannot use the binary.

I'm using a custom RHEL image:https://hub.docker.com/r/scholarpack/python

I'm not sure if there are some new OS dependencies now, or is this is related to the new build process for Mac and Linux (2.9 release):

Build system for Linux/MacOS binary packages moved to GitHub action.

@dvarrazzo
Copy link
Member

have you updated pip?

@dvarrazzo
Copy link
Member

dvarrazzo commented Jul 11, 2021

Deleted comment from OP: from some random dude

I have this also. Recently updated pip to 21.1.3 on Mac aarch64.

Dupe of #1286

@CoburnJoe
Copy link
Author

Hi @dvarrazzo The linked #1286 is referencing M1/ARM architecture - I'm using an Intel Mac - is the root cause one and the same?

Also, fyi the comment you deleted wasn't from me :)

@dvarrazzo
Copy link
Member

dvarrazzo commented Jul 12, 2021

@CoburnJoe, sorry, will address the comment attribution.

As for why pip doesn't install the package for you: download the package you think it should install from PyPI and try to install it. What is the error message?

@CoburnJoe
Copy link
Author

@dvarrazzo This is the error message when installing from PyPi:

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.

@dvarrazzo
Copy link
Member

No, that's not the error you get from PyPI. That's the error you get from psycopg's setup.py because PyPI has decided that it doesn't want to install the binary package that is supposedly compatible with your machine. So you should look at why pip won't install that.

In this list of files: https://pypi.org/project/psycopg2-binary/#files what is the package that PyPI should install?

  • look for the one named macos_intel and py39 (adjust according to your python version)
  • run pip install -v URL with the url the package
  • is there any interesting error message?

@snelson3
Copy link

I have the same error in my Jenkins CI pipeline, that has been happening for the last few weeks, with installs working fine before then (nothing major in the CI configuration has changed).

It is a CentOS based docker image and the base image has not changed in several months

Requirements.txt specifies installing "psycopg2-binary"

Collecting psycopg2-binary (from -r /opt/user/requirements.txt (line 33))
  Downloading https://files.pythonhosted.org/packages/14/65/223a5b4146b1d5d5ab66f16ef194916a1ed9720da1f118d7bfb60b8f2bea/psycopg2-binary-2.9.1.tar.gz (380kB)
�[91m    ERROR: Command errored out with exit status 1:
     command: /usr/local/bin/python3.7 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-efnoa5dd/psycopg2-binary/setup.py'"'"'; __file__='"'"'/tmp/pip-install-efnoa5dd/psycopg2-binary/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base pip-egg-info
         cwd: /tmp/pip-install-efnoa5dd/psycopg2-binary/
    Complete output (23 lines):
    running egg_info
    creating pip-egg-info/psycopg2_binary.egg-info
    writing pip-egg-info/psycopg2_binary.egg-info/PKG-INFO
    writing dependency_links to pip-egg-info/psycopg2_binary.egg-info/dependency_links.txt
    writing top-level names to pip-egg-info/psycopg2_binary.egg-info/top_level.txt
    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
    <https://www.psycopg.org/docs/install.html>).
    
    ----------------------------------------
�[0m�[91mERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

@dvarrazzo
Copy link
Member

@ Both of you: what version of pip are you using?

@CoburnJoe
Copy link
Author

@dvarrazzo I can confirm that I'm using Pip version 19.2.3.
Switching to Pip 21.1.3 and it works again! Thanks for your help!

@dvarrazzo
Copy link
Member

And why you didn't do it as I asked 5 days ago? Or as written on top of the install docs page? Out of curiosity...

@CoburnJoe
Copy link
Author

And why you didn't do it as I asked 5 days ago? Or as written on top of the install docs page? Out of curiosity...

It's not that simple:

  • I was away from my computer for a few days
  • You also closed this issue as a dupe of m1 Mac issues
  • We are running a custom base image
    etc

May I suggest an issue template pointed to an FAQ could help avoid erroneous issues like this?

@CoburnJoe
Copy link
Author

Also worth noting that upgrading pip worked for me, but the now deleted comment refers to issues with the latest version of pip 21.1.3:

I have this also. Recently updated pip to 21.1.3 on Mac aarch64.

@dvarrazzo
Copy link
Member

Because that's an issue with a mac M1, which you confirmed you don't have.

@dvarrazzo
Copy link
Member

And yes, I had a never merged branch to add an issue template. It's proving worth to finish it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants