How to find pg_config path

Complete the newbie here by trying to configure Django to work with ProstgreSQL.

I am using mac osx 10.6.8. I also installed PostgreSQL 9.3

When I run pip install psycopg2 in the terminal, I get the following error

 Downloading/unpacking psycopg2 Downloading psycopg2-2.5.2.tar.gz (685kB): 685kB downloaded Running setup.py (path:/private/var/folders/A9/A99cs6x0FNusPejCVkYNTE+++TI/-Tmp-/pip_build_bengorman/psycopg2/setup.py) egg_info for package psycopg2 Error: pg_config executable not found. 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'. Complete output from command python setup.py egg_info: running egg_info creating pip-egg-info/psycopg2.egg-info writing pip-egg-info/psycopg2.egg-info/PKG-INFO writing top-level names to pip-egg-info/psycopg2.egg-info/top_level.txt writing dependency_links to pip-egg-info/psycopg2.egg-info/dependency_links.txt writing manifest file 'pip-egg-info/psycopg2.egg-info/SOURCES.txt' warning: manifest_maker: standard file '-c' not found Error: pg_config executable not found. 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 saw several posts on this site how-to-install-psycopg2-with-pip-on-python
pg-config-executable-not-found

but I do not know how to find the folder with the bin folder containing pg_config. Any tips on finding this way?

+46
python django postgresql macos
Jan 12 '14 at 20:20
source share
11 answers

I recommend you try using Postgres.app. ( http://postgresapp.com ) This way you can easily enable and disable Postgres on your Mac. After that, add the path to Postgres to your .profile file by adding the following:

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

Only after you have added Postgres to your path, you can try installing psycopg2 either in a virtual environment (using pip) or in your global site packages.

+72
Jan 12 '14 at 21:48
source share

Postgres.app has recently been updated. Now it saves all binary files in the Versions folder

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

Where 9.4 is the version of PostgreSQL.

+23
Aug 18 '14 at 7:06
source share
 sudo find / -name "pg_config" -print 

Answer: /Library/PostgreSQL/9.1/bin/pg_config in my configuration (MAC Maverick)

+21
Mar 31 '14 at 12:45
source share

Homebrew Installation

 /usr/bin/ruby -e "$(curl -fsSL https://raw.github.com/gist/323731)" 

And then install postgresql

 brew install postgresql 

gave me this beautiful exit bit:

 checking for pg_config... yes 

ahhh yeahhhhh

+15
Nov 05 '14 at 18:32
source share

After installing the current PostgreSQL application on MacOS X 10.11, this is the pg_config /Library/PostgreSQL/9.5/bin/pg_config file.

Then on the terminal:

  $ export PG_HOME=/Library/PostgreSQL/9.5 $ export PATH=$PATH:$PG_HOME/bin 

This will put the path in the .profile of any terminal that you use.

In your environment (assuming you are using virtualenv ), you then install psycopg2:

  $ pip install psycopg2 

You should see if you downloaded it before:

  Collecting psycopg2 Using cached psycopg2-2.6.1.tar.gz Installing collected packages: psycopg2 Running setup.py install for psycopg2 ... done Successfully installed psycopg2-2.6.1 
+11
Feb 05 '16 at 16:13
source share

To summarize - PostgreSQL installs its files (including its binary or executable files) in different places, depending on the version number and installation method.

Some of the features are:

 /usr/local/bin/ /Library/PostgreSQL/9.2/bin/ /Applications/Postgres93.app/Contents/MacOS/bin/ /Applications/Postgres.app/Contents/Versions/9.3/bin/ 

No wonder people get confused!

In addition, if the environment variable $ PATH includes the path to the directory that includes the executable (to confirm this, use echo $PATH on the command line), then you can run which pg_config , which psql , etc. to find where the file is located .

+7
Jan 30 '15 at 2:10
source share

I had exactly the same error, but I installed postgreSQL via brew and restarted the original command and it worked perfectly:

brew install postgresql

+5
Mar 30 '15 at 15:48
source share

You can find the pg_config directory using its tag:

 $ pg_config --bindir /usr/lib/postgresql/9.1/bin $ 

Tested on Mac and Debian. The only wrinkle is that I don’t see how to find bindir for different versions of postgres installed on the same computer. It's pretty easy to guess though !:-)

Note. I upgraded my pg_config to 9.5 on Debian using

 sudo apt-get install postgresql-server-dev-9.5 
+2
May 12 '16 at 16:05
source share

check out / Library / PostgreSQL / 9.3 / bin and you should find pg_config

those. /Library/PostgreSQL/<version_num>/

ps: you can do the following if you consider it necessary for your needs pg -

create .profile in ~ directory

 export PG_HOME=/Library/PostgreSQL/9.3 export PATH=$PATH:$PG_HOME/bin 

Now you can use psql or postgres commands from the terminal, and also install psycopg2 or any other dependency without problems, plus you can always just ls $PG_HOME/bin when you want to look into your pg_dir.

+1
Nov 18 '15 at 6:28
source share

I used:

 export PATH=$PATH:/Library/PostgreSQL/9.6/bin pip install psycopg2 
+1
Oct 08 '16 at 1:19
source share

You have the same problem on Mac, you probably need

brew install postgresql

then you can run

pip install psycopg2

brew will fix the PATH problem for you

this solution works for me at least.

0
Mar 14 '17 at 12:02 on
source share



All Articles