hackoregon / transportation-backend

Transportation backend repo - 2016 and 2017
8 stars 7 forks source link

Command "python setup.py egg_info" failed with error code 1 #49

Closed MikeTheCanuck closed 7 years ago

MikeTheCanuck commented 7 years ago

I followed the transportation-backend/README.md instructions up to the pip install on a clean High Sierra MacBook:

git clone https://github.com/hackoregon/transportation-backend.git
cd transportation-backend
virtualenv -p python3 venv
source venv/bin/activate
pip install -r ./transDjango/requirements.txt

And this is the output I received:

$ git clone git@github.com:hackoregon/transportation-backend.git
Cloning into 'transportation-backend'...
Enter passphrase for key '/Users/mike/.ssh/id_rsa': 
remote: Counting objects: 1437, done.
remote: Total 1437 (delta 0), reused 0 (delta 0), pack-reused 1437
Receiving objects: 100% (1437/1437), 8.71 MiB | 6.64 MiB/s, done.
Resolving deltas: 100% (936/936), done.
$ cd transportation-backend/
$ virtualenv -p python3 venv
Running virtualenv with interpreter /Library/Frameworks/Python.framework/Versions/3.6/bin/python3
Using base prefix '/Library/Frameworks/Python.framework/Versions/3.6'
New python executable in /Users/mike/code/transportation-backend/venv/bin/python3
Also creating executable in /Users/mike/code/transportation-backend/venv/bin/python
Installing setuptools, pip, wheel...source done.
$ source venv/bin/activate
(venv) $ pip install -r ./transDjango/requirements.txt 
Collecting Django==1.10.5 (from -r ./transDjango/requirements.txt (line 1))
  Using cached Django-1.10.5-py2.py3-none-any.whl
Collecting django-cors-headers==2.0.2 (from -r ./transDjango/requirements.txt (line 2))
  Downloading django_cors_headers-2.0.2-py2.py3-none-any.whl
Collecting django-leaflet==0.19.0 (from -r ./transDjango/requirements.txt (line 3))
  Downloading django-leaflet-0.19.0.zip (238kB)
    100% |████████████████████████████████| 245kB 3.4MB/s 
Collecting djangorestframework==3.5.4 (from -r ./transDjango/requirements.txt (line 4))
  Using cached djangorestframework-3.5.4-py2.py3-none-any.whl
Collecting djangorestframework-gis==0.11 (from -r ./transDjango/requirements.txt (line 5))
  Downloading djangorestframework_gis-0.11-py2.py3-none-any.whl
Collecting django-rest-swagger==2.1.1 (from -r ./transDjango/requirements.txt (line 6))
  Using cached django_rest_swagger-2.1.1-py2.py3-none-any.whl
Collecting psycopg2==2.6.2 (from -r ./transDjango/requirements.txt (line 7))
  Using cached psycopg2-2.6.2.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'
    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/xy/dyk7652d0h5b3_83hj2274g80000gn/T/pip-build-4xb7ph5v/psycopg2/
nam20485 commented 7 years ago

This is a common error when setting up django and postgres. The requirements.txt calls for installing the psycopg2 python module, but psycopg2 has a dependency on libpq-dev system library. So that module must be installed prior to running the pip install command from your steps listing. Running the following command just prior should fix the error:

sudo apt-get install python-dev libpq-dev postgresql-contrib