Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to install psycopg2 on Windows

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:\users\Tony> 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-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'.

----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in c:\users\Tony\appdata\local\temp\pip-build-dobxew\psycopg2

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 III\1.20) How to access the PostgreSQL database using Python then?

like image 723
MSS Avatar asked Oct 26 '25 07:10

MSS


1 Answers

For all those that got the same problem in 2019, the correct way to install it via pip is now :

pip install psycopg2-binary
like image 54
Alan Avatar answered Oct 28 '25 19:10

Alan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!