1

I am trying to install psycopg2-binary into my Django project. I am using a virtual environment and the command I'm running is

pip install psycopg2-binary

However, I'm getting a massive error message, the gist of it is this:

    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.

But, hey, I'm installing exactly 'psycopg2-binary'

Why am I getting all this mess?

Sundraw
  • 207
  • 2
  • 11
  • Platform/processor architecture? OS? Python version? Is Python 32- or 64-bit? (Please be careful, it's possible to run 32-bit Python on a 64-bit OS.) – phd Nov 17 '21 at 18:09
  • macOS, M1, Python 3.8, not sure how to find out whether it's 32 or 64-bit – Sundraw Nov 18 '21 at 10:29
  • I've now installed Python 3.10 from python.org, and it is 64-bit. Tried to install psycopg2-binary again, same result. – Sundraw Nov 18 '21 at 10:38
  • if you land here experiencing this problem, see [this github issue](https://github.com/psycopg/psycopg2/issues/1286) for a test build of psycopg2-binary you can use – takecare Jul 28 '22 at 10:23

2 Answers2

1

Pip cannot find you processor+OS at https://pypi.org/project/psycopg2-binary/2.9.2/#files so it tried to install from sources (the last file at the page) and failed.

Compiling from sources is currently the only way. If you can donate some spare processor cycles to the Psycopg2 authors they perhaps could start compiling and publishing wheels for OSX on M1.

phd
  • 82,685
  • 13
  • 120
  • 165
1

I ran into a similar problem, except that I had been successfully installing this package on other instances. What happened is they upped the version number of the package and the installer could not find it. It was looking for 2.9.6, and when i forced version 2.9.5 it installed the binary without problem.

Ben
  • 11
  • 2