1

I'm learning how to use Postgres with Python (sqlalchemy). I'm stuck when installing psycopg2. I have the following error :

pg_config executable not found error

I know that's a very common error and there is already a lot of answers about this but I couldn't find anything to help me solve my issue.

I especially don't understand this answers :

add the path to Postgres to your .profile file by appending the following:

PATH="/Applications/Postgres.app/Contents/Versions/latest/bin:$PATH"

What does it mean ? what should I do exactly ?

I also tried to enter which -a pg_configin my terminal but nothing happen.

Thanks a lot !

Community
  • 1
  • 1
Simon Breton
  • 2,009
  • 4
  • 27
  • 69
  • 1
    What's unclear about that solution? You need to change the environment variable `PATH` so that `pg_config` can be found. – Laurenz Albe Jan 19 '17 at 11:49
  • should I do this from my terminal ? what should I enter exactly ? – Simon Breton Jan 19 '17 at 11:51
  • 2
    You could just type this into your terminal: `PATH="/Applications/Postgres.app/Contents/Versions/latest/bin:$PATH"` (if that's indeed the path where `pg_config` is found), then press enter. Then build `psycopg2`. – Laurenz Albe Jan 19 '17 at 11:55
  • when I'm using my mac search bar for "pg_config" I can't find anything. and where doing `which -a pg_config` in my terminal nothing happen. – Simon Breton Jan 19 '17 at 11:57
  • Maybe there is a PostgreSQL development package that you didn't install and that contains `pg_config`. – Laurenz Albe Jan 19 '17 at 11:58
  • Thanks for your help. How do I know that ? looking at my application folder I only have Postgres and PSequel – Simon Breton Jan 19 '17 at 12:00
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/133543/discussion-between-simon-breton-and-laurenz-albe). – Simon Breton Jan 19 '17 at 12:01

1 Answers1

4

The problem was solved by typing

PATH="/Applications/Postgres.app/Contents/Versions/latest/bin:$PATH"

into the terminal window prior to installing psycopg2.

Laurenz Albe
  • 129,316
  • 15
  • 96
  • 132