0

I'm trying to install psycopg2 to use a postgresql db in the backend of my django project, but every time I run the pip install psycopg2 command I get an error saying:

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

I have added the \bin\ folder containing the file to my path, I've ran the pip install psycopg2-binary command as well, and I've uninstalled and reinstalled posgresql on my computer, I've also ran the python setup.py build_ext command mentioned in the error message, and this error still pops up. I'm operating on a windows 10 os and using posgresql 13.1. Any suggestions?

EDIT: This is the error I'm getting in my terminal:

Error in PyCharm terminal

RusskiT
  • 106
  • 7

1 Answers1

0

You've probably done this already, but the steps should be:

  1. Install PostgreSQL.
  2. Add the PostgreSQL bin/ folder to your path.
  3. Restart your command line to make sure your path is set correctly.
  4. Run pip install psycopg2

I have a clean install of Windows 10 over here and it seems to work for me. Running pip install psycopg2-binary should definitely work (even without PostgreSQL) because that doesn't compile anything, so I'm interested if you also have errors there.

Exelian
  • 5,749
  • 1
  • 30
  • 49
  • I've re-installed PostgreSQL and added the folder, and the install works when I open up my powershell in the root directory, but PyCharm keeps throwing the error at me. I'm positive my path is set up correclty. This does the same thing with Pillow – RusskiT Nov 17 '20 at 17:45