AnApprentice
AnApprentice

Reputation: 111080

PostgreSQL - pg_config -bash: pg_config: command not found

I'm on a Mac building an app in Rails 3 with PostgreSQL...

PostgreSQL is working fine but in the command line I get the following error:

$ pg_config
-bash: pg_config: command not found

Anyone know how to get this setup so I can run pg_config?

Thanks

Upvotes: 36

Views: 67576

Answers (7)

cmucheru
cmucheru

Reputation: 159

Find where pg_config is located: find / -name pg_config 2>/dev/null Copy the path then do: export PATH=/usr/local/pgsql/bin:$PATH. Make sure to use your correct copied path.

Upvotes: 1

martinkaburu
martinkaburu

Reputation: 586

pg_config is a PostgreSQL util, you can get it by installing PostgreSQL. On mac:

brew install postgresql

Upvotes: 3

dimid
dimid

Reputation: 7659

In addition to installing postgresql-devel I had to modify the PATH environment variable. E.g. add this to your .bashrc:

export PATH="$PATH:/usr/pgsql-9.4/bin"

Upvotes: 9

Anwar
Anwar

Reputation: 1805

My problem was that pg_config was not in the PATH. So, I first needed to search for pg_config's path by using

yum provides "*/pg_config"

After noting the path, I used this command to install pg gem

gem install pg -- --with-pg-config=/usr/pgsql-9.4/bin/pg_config

That installed pg successfully. The system was a CentOS.

Upvotes: 4

Paul Giancarlo Diaz
Paul Giancarlo Diaz

Reputation: 41

i have a CentOS 5.11 with postgres 9.0, and python 2.4 , python 2.6 to run openERP 6, trying to install the psycopg2 i allways get the error:

# python26 setup.py install --with-xslt-config=/usr/local/bin/xslt-config --with-xml2-config=/usr/local/bin/xml2-config
usage: setup.py [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
   or: setup.py --help [cmd1 cmd2 ...]
   or: setup.py --help-commands
   or: setup.py cmd --help

error: option --with-xslt-config not recognized

from :how to install pg_config Later i do :

yum provides "*/pg_config"

i get a list, where we can find

postgresql84-devel-8.4.20-1.el5_10.x86_64 : PostgreSQL development header     files
                                          : and libraries
Repo        : base
Matched from:
Filename    : /usr/bin/pg_config

but if i try to install, its already installed So i use

yum provides "*/pg_config"

later you need install the rigth vertion, for your architecture(32bit or 64bit), in my case was:

yum install postgresql84-devel-8.4.20-1.el5_10.x86_64

then update

yum update

and finally install psycopg2 with pip

pip install psycopg2

Upvotes: 0

Unni
Unni

Reputation: 1781

you can install postgresql-devel to get that. in rpm based distro

yum install postgresql-devel

will work

or use

yum provides "*/pg_config"

to get the exact package

Upvotes: 69

Ignacio Vazquez-Abrams
Ignacio Vazquez-Abrams

Reputation: 799490

pg_config comes with the development files for PostgreSQL. Go to where you got the server daemon from and look for them there.

Upvotes: 0

Related Questions