3

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 can't seem to solve the latest one. When I run:

setup.py install

on the psycopg2 in the command console it attempts to install it, but then gives an error when trying to execute link.exe in 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. However, it keeps giving:

"error: command C:\Program Files(x86)\Microsoft Visual Studio 9.0\VC\BIN\link.exe" failed with exit status 1120
nik7
  • 806
  • 3
  • 12
  • 20
kag359six
  • 1,693
  • 2
  • 16
  • 21

4 Answers4

11

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.

nik7
  • 806
  • 3
  • 12
  • 20
Andrew Allen
  • 6,512
  • 5
  • 30
  • 73
5

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

kag359six
  • 1,693
  • 2
  • 16
  • 21
2

Had the same problem.

Image of the error message

first run sudo apt install libpq-dev python3-dev

then pip3 install psycopg2

Vitória Calil
  • 131
  • 1
  • 3
0

Go to https://pypi.org/project/psycopg2.

In release history select the version you want to download: there will be a table with files and compatible versions of Python.

Download the binary file that matches your system configuration.

For example, for Python 3.6 on Windows 10 (64-bit) download psycopg2-2.8.6-cp36-cp36m-win_amd64.whl.

nik7
  • 806
  • 3
  • 12
  • 20