Can't install psycopg2

2019-07-15 02:51发布

问题:

I'm trying to install psycopg2 so I can use postgresQL in python and Django. I have run into multiple errors in the last few hours trying to install it, and my latest one I can't seem to solve. When I run setup.py install on the psycopg2 in the command console it attempts to install it, but then gives me an error when trying to execute link.exein the Visual Studio 8 folder. This doesn't make sense to me, considering I got that executable to work when I launch it from Windows Explorer, and from the command console. I even made an environment variable for it. For some reason it keeps telling me "error: command C:\Program Files(x86)\Microsoft Visual Studio 9.0\VC\BIN\link.exe" failed with exit status 1120 I've looked extensively for a solution to this but everything I have tried didn't work. Anybody have suggestions or possible solutions?

回答1:

Turns out this 3 and a half hour process I've been going through was unecessary. an exe installer of psycopg2 can be downloaded from here



回答2:

In case anyone goes down this rabbit hole also, make sure your pip is up-to-date

pip install -U pip

pip install psycopg2-binary

See - http://initd.org/psycopg/docs/install.html

That's 3 hours of my life I won't get back.



回答3:

o to https://pypi.org/project/psycopg2 in release history select the version u want to dwnld there will be a table with files and the versions of python that can be compatible with the selected version now download the binary file that matches ur system congfiguration(mac/linux/win-32/win-64)

i did this and was able to download the package

for windows10(64-bit) download 'psycopg2-2.7.7-cp36-cp36m-win_amd64.whl (998.5 kB)' incase you have selected 2.7.7