I am trying to use postgresql in my Django project so I have been trying to install psycopg2 however I keep running into problems. Since I am using a virtualenv, installing psycopg2 through macports isn't helping. I need to find someway to install it as an app within my virtual env.
Here is the error I get when I try to pip install it in my virtualenv:
Downloading/unpacking psycopg2
Downloading psycopg2-2.5.4.tar.gz (682kB): 682kB downloaded
Running setup.py (path:/Users/adfelix2/Documents/Hindsait_Work/Projects/nybc_pilot/build/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'.
----------------------------------------
Cleaning up...
Command python setup.py egg_info failed with error code 1 in /Users/user/'privateinfo'/my_virtualenv/build/psycopg2
Storing debug log for failure in /Users/user/.pip/pip.log
Seems like I need to add a directory to pg_config? However I am unable to come across anything online that would help me do so. If anybody has an answer to this, in a step-by-step manner, it would be very gladly appreciated. Thank you.
If you run error like this then you need install two packages.
sudo apt-get install libpq-dev python-dev
now install psycopg2
pip install psycopg2
If you have installed the Postgres.app, the one that sits in the Mac's menu bar, you will have to point your path at the pg_config executable in the App's bundle. You can navigate to the executable by visiting
/Applications/Postgres.app/Contents/Versions/9.3/bin
where your version would depend on what you have installed. Add this to to your $PATH variable in your .bash_profile, reload it, and voila!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With