I work in a office where the PostgreSQL has been installed on server.
On my windows machine, I have pgAdmin III 1.20 installed to access the database.
I am trying to install psycopg2 in my windows system. I get this error:
C:usersTony> pip install psycopg2
Collecting psycopg2
Using cached psycopg2-2.6.1.tar.gz
Complete output from command python setup.py egg_info:
running egg_info
creating pip-egg-infopsycopg2.egg-info
writing pip-egg-infopsycopg2.egg-infoPKG-INFO
writing top-level names to pip-egg-infopsycopg2.egg-infotop_level.txt
writing dependency_links to pip-egg-infopsycopg2.egg-infodependency_links.txt
writing manifest file 'pip-egg-infopsycopg2.egg-infoSOURCES.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'.
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in c:usersTonyappdatalocaltemppip-build-dobxewpsycopg2
I know that pg_config is available in the bin folder of the PostgreSQL. But I cannot access that location in server. Without pg_config file, I am unable to install psycopg2 in my local windows machine. I read somewhere that libpq.dll is required while building psycopg2.So I have added path of libpq.dll present in pgAdmin III 1.20 into my system path.(C:Program Files (x86)pgAdmin III1.20)
How to access the PostgreSQL database using Python then?
2
For all those that got the same problem in 2019, the correct way to install it via pip is now :
pip install psycopg2-binary
run this command:
python -m pip install Psycopg2
Note:
Open the commandprompt in the same folder as project
The following will install prebuilt binaries for windows from this site.
pip install pipwin
pipwin install psycopg2
Download psycopg2
version for your python and windows from here win-psycopg
Do NOT double-click the package to run. Instead, use easy_install from either setuptools or distribute.
C:> easy_install psycopg2-2.6.1.win32-py2.7-pg9.4.4-release.exe
0