Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Install psycopg2 on Ubuntu

I'm trying to get the python postgres client module installed on Ubuntu 12.04. The guidance is to do the following:

apt-get install python-psycopg2

However, apt says that the package can't be located.
I'm keen to install this through apt. Is this part of another package that I can install?

like image 745
Matt Avatar asked Jul 20 '12 16:07

Matt


4 Answers

This works for me in Ubuntu 12.04 and 15.10

if pip not installed:

sudo apt-get install python-pip

and then:

sudo apt-get update
sudo apt-get install libpq-dev python-dev
sudo pip install psycopg2
like image 143
Renato Prado Avatar answered Oct 16 '22 13:10

Renato Prado


Using Ubuntu 12.04 it appears to work fine for me:

jon@minerva:~$ sudo apt-get install python-psycopg2
[sudo] password for jon: 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Suggested packages:
  python-psycopg2-doc
The following NEW packages will be installed
  python-psycopg2
0 upgraded, 1 newly installed, 0 to remove and 334 not upgraded.
Need to get 153 kB of archives.

What error are you getting exactly? - double check you've spelt psycopg right - that's quite often a gotcha... and it never hurts to run an apt-get update to make sure your repo. is up to date.

like image 34
Jon Clements Avatar answered Oct 16 '22 12:10

Jon Clements


Use

sudo apt-get install python3-psycopg2

for Python3 )

like image 39
Ilya Sheroukhov Avatar answered Oct 16 '22 12:10

Ilya Sheroukhov


This worked for me:

pip install psycopg2-binary
like image 8
Martin Alexandersson Avatar answered Oct 16 '22 13:10

Martin Alexandersson