OpenStack Dev: Error on tox with psycopg2

Posted by Kairo Araujo on Fri 19 February 2016 Updated on Fri 19 February 2016

I am a beginner on OpenStack project, but I am very proud about this. Such as beginner I am getting some problems, maybe easy problems for senior developers but not for me. And I'll try to show here the solutions.

I was trying to create my first propose for Ceilometer project.

I was working on hacking for ceilometer. This hacking check the code to be accomplished with PEP8 and others another rules for the code. More about the Hacking you can see on http://docs.openstack.org/developer/hacking/

Well, after change all code I was tryint to execute the tox to check the pep8 and compatibility with py27 and py34.

I use Mac OS and I was receiving this error when I was trying to execute the tox:

    kairo-macair:ceilometer kairoaraujo$ tox -e pep8,py27
    ...
    Collecting psycopg2>=2.5 (from -r /Users/kairoaraujo/Dev/OpenStack/ceilometer/test-requirements.txt (line 22))
    Using cached psycopg2-2.6.1.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 dependency_links to pip-egg-info/psycopg2.egg-info/dependency_links.txt
        writing top-level names to pip-egg-info/psycopg2.egg-info/top_level.txt
        writing manifest file 'pip-egg-info/psycopg2.egg-info/SOURCES.txt'
        warning: manifest_maker: standard file '-c' not found

        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'.

        ----------------------------------------
    Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/pq/1q6gn01s5yzbkt4cqv_qqf6w0000gn/T/pip-build-DkIQsr/psycopg2

    _____________________________________________ summary ______________________________________________
    ERROR:   pep8: could not install deps [-r/Users/kairoaraujo/Dev/OpenStack/ceilometer/requirements.txt, -r/Users/kairoaraujo/Dev/OpenStack/ceilometer/test-requirements.txt]; v = InvocationError('/Users/kairoaraujo/Dev/OpenStack/ceilometer/.tox/pep8/bin/pip install -U -r/Users/kairoaraujo/Dev/OpenStack/ceilometer/requirements.txt -r/Users/kairoaraujo/Dev/OpenStack/ceilometer/test-requirements.txt (see /Users/kairoaraujo/Dev/OpenStack/ceilometer/.tox/pep8/log/pep8-1.log)', 1)
    ERROR:   py27: could not install deps [-r/Users/kairoaraujo/Dev/OpenStack/ceilometer/requirements.txt, -r/Users/kairoaraujo/Dev/OpenStack/ceilometer/test-requirements.txt]; v = InvocationError('/Users/kairoaraujo/Dev/OpenStack/ceilometer/.tox/py27/bin/pip install -U -r/Users/kairoaraujo/Dev/OpenStack/ceilometer/requirements.txt -r/Users/kairoaraujo/Dev/OpenStack/ceilometer/test-requirements.txt (see /Users/kairoaraujo/Dev/OpenStack/ceilometer/.tox/py27/log/py27-1.log)', 1)

To fix it is easy.

After some research I found a solution (sorry, I lose the link).

  1. Go to http://postgres.org

  2. Download the Mac OS X package http://www.postgresql.org/download/macosx/

  3. Install the Postgres.app

  4. Change your ~/.bash_profile and add it:

    4.1 Attention for your version here

    #OpenStack Development
    export PATH=${PATH}:/Applications/Postgres.app/Contents/Versions/9.5/bin/
    
  5. Try to run tox or install psycopg2 using pip again.