Search code examples
postgresqlpython-2.7psycopg2libpqlibpqxx

error in installing libpq-dev in ubuntu 14.04 after installing psycopg2


I am trying to install all requirements of a project so i run the command

pip install -r requirements.txt

but it gives the error

Downloading/unpacking psycopg2==2.6 (from -r requirements.txt (line 58))
  Downloading psycopg2-2.6.tar.gz (367kB): 367kB downloaded
  Running setup.py (path:/tmp/pip_build_root/psycopg2/setup.py) egg_info for package psycopg2

    Error: b'You need to install postgresql-server-dev-X.Y for building a server-side extension or libpq-dev for building a client-side application.\n'
    Complete output from command python setup.py egg_info:
    running egg_info

creating pip-egg-info/psycopg2.egg-info

writing top-level names to pip-egg-info/psycopg2.egg-info/top_level.txt

writing pip-egg-info/psycopg2.egg-info/PKG-INFO

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: b'You need to install postgresql-server-dev-X.Y for building a server-side extension or libpq-dev for building a client-side application.\n'

----------------------------------------
Cleaning up...
Command python setup.py egg_info failed with error code 1 in /tmp/pip_build_root/psycopg2
Storing debug log for failure in /home/admin/.pip/pip.log

now i knew that i have to install postgresql-server so i used following command

sudo apt-get install postgresql

all good till now and then i ran

sudo apt-get install python-psycopg2

and then i ran my command to install requirements again but got the same error and then i searched on google and tried

sudo apt-get install libpq-dev

but i got following error

Reading package lists... Done
Building dependency tree       
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 libpq-dev : Depends: krb5-multidev but it is not going to be installed
             Depends: comerr-dev but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

now i am unable to detect and correct broken package...please help me...


Solution

  • I ran the following commands to repair broken package and then i successfully installed Psycopg2 and Postgresql ...

    sudo apt-get update
    sudo apt-get install python-dev
    sudo apt-get install libpq-dev
    sudo apt-get install krb5-multidev
    sudo apt-get install libssl1.0.0=1.0.1f-1ubuntu2 ibcomerr2=1.42.9-3ubuntu1
    sudo apt-get install libssl1.0.0=1.0.1f-1ubuntu2
    sudo apt-get install ibcomerr2=1.42.9-3ubuntu1
    sudo apt-get update
    sudo apt-get install libpq-dev
    apt-get install libssl-dev krb5-multidev comerr-dev
    sudo apt-get install libssl-dev krb5-multidev comerr-dev
    sudo apt-get dist-upgrade
    
    sudo apt-get update
    sudo apt-get install libssl-dev krb5-multidev comerr-dev
    sudo apt-get install libcomerr2
    sudo apt-get install comerr-dev
    sudo apt-get install libcomerr2
    sudo apt-get install comerr-dev
    sudo apt-get install comerr-dev
    sudo apt-get install 1.42.9-3ubuntu1.3
    sudo apt-get install ibcomerr2=1.42.9-3ubuntu1
    sudo apt-get install git
    git clone https://github.com/kos0/addRemoveDistribution.git
    cd addRemoveDistribution
    sudo ./enableDisableDistribution.pl enable security
    sudo ./enableDisableDistribution.pl enable updates
    sudo apt-get update
    sudo apt-get install libpq-dev
    sudo apt-get update
    pip install -r requirements.txt