3

My projects is running postgreSQL and after I upgraded my system to ubuntu 16.04, and cloned the project again, I am not able to install the particular package.

I have also tried to purge postgresql and psycopg2 but am not able to install it

(temp) hellrazor@hellrazor-desktop:~/workspace/te___ave/backend/te___ave$ pip install psycopg2==2.6 > ERROR.txt
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-f6rRmm/psycopg2/
(temp) hellrazor@hellrazor-desktop:~/workspace/te___ave/backend/te___ave$ 

This is the error I am getting

Collecting psycopg2==2.6
  Using cached psycopg2-2.6.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'
    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'.

    ----------------------------------------

I did all the steps written in https://help.ubuntu.com/community/PostgreSQL#Client_Installation

Also in some answer in pg_config executable not found I saw that I needed to add sudo apt-get install libpq-dev python-dev

but it gave this output

(temp) hellrazor@hellrazor-desktop:~/workspace/teamwave/backend/teamwave$ sudo apt-get install libpq-dev python-dev
Reading package lists... Done
Building dependency tree       
Reading state information... Done
python-dev is already the newest version (2.7.11-1).
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: libpq5 (= 9.5.10-0ubuntu0.16.04) but 10.1-1.pgdg16.04+1 is to be installed
E: Unable to correct problems, you have held broken packages.

I am trying to find how to resolve the error but not getting any leads now.

shubhendu
  • 299
  • 2
  • 16

1 Answers1

3

I think you're encountering issues with the fact that you've version-locked psycopg2. You've locked to version 2.6, which has some known build issues that are resolved in later versions.

If you read the release notes, found here: http://initd.org/psycopg/docs/news.html#what-s-new-in-psycopg-2-7-4 you will see that version 2.7 and 2.7.4 both fix bugs pertaining to building and installing the package.

My guess is that your previous installation of Linux was running an older version of Postgres (9.5, I think). However, now that you upgraded your OS, you inadvertantly upgraded to version 10.

Here are four different solutions to try, but first you may need to

  1. Ensure you PostgreSQL installation is configured properly so pg_config can be run from your terminal.
  2. Remove the version lock in your pip installation with pip install psycopg2
  3. Version lock your libpq-dev package to a version suited to PostgreSQL 9.5
  4. Reinstall PostgreSQL to version 9.5 if you don't need version 10
David House
  • 101
  • 3