简体   繁体   中英

psycopg2 error on heroku

I have been trying to run a node webserver and django backend server on one dyno following this guide .

My ProcfileHoncho looks like:

node: cd src-backbone && npm install --production
python: cd src-django && pip install -r requirements.txt && gunicorn 
myapp.wsgi:application --bind 127.0.0.1:8000

When I run pip install requirements.txt from my Procfile it tries to install psycopg2==2.6.1 but it seems to crash every time because psycopg2 cannot find pg_config which is part of the PostgreSQL library usually.

I already created (and I assume attached) the Postgres addon to my application but I cannot get the installation to work.

Any suggestions?

2018-02-19T20:47:29.441881+00:00 app[web.1]: 20:47:29 python.1 | Collecting djangorestframework==3.3.2 (from -r requirements.txt (line 13))
2018-02-19T20:47:29.636583+00:00 app[web.1]: 20:47:29 python.1 |   Downloading djangorestframework-3.3.2-py2.py3-none-any.whl (634kB)
2018-02-19T20:47:29.948376+00:00 app[web.1]: 20:47:29 python.1 | Collecting factory-boy==2.6.1 (from -r requirements.txt (line 14))
2018-02-19T20:47:30.007044+00:00 app[web.1]: 20:47:30 python.1 |   Downloading factory_boy-2.6.1-py2.py3-none-any.whl
2018-02-19T20:47:30.134889+00:00 app[web.1]: 20:47:30 python.1 | Collecting flake8==2.5.4 (from -r requirements.txt (line 15))
2018-02-19T20:47:30.224808+00:00 app[web.1]: 20:47:30 python.1 |   Downloading flake8-2.5.4-py2.py3-none-any.whl
2018-02-19T20:47:30.349474+00:00 app[web.1]: 20:47:30 python.1 | Collecting freezegun==0.3.6 (from -r requirements.txt (line 16))
2018-02-19T20:47:30.445518+00:00 app[web.1]: 20:47:30 python.1 |   Downloading freezegun-0.3.6-py2.py3-none-any.whl
2018-02-19T20:47:30.619753+00:00 app[web.1]: 20:47:30 python.1 | Collecting gunicorn==19.4.5 (from -r requirements.txt (line 17))
2018-02-19T20:47:30.713577+00:00 app[web.1]: 20:47:30 python.1 |   Downloading gunicorn-19.4.5-py2.py3-none-any.whl (112kB)
2018-02-19T20:47:30.869301+00:00 app[web.1]: 20:47:30 python.1 | Collecting jinja2==2.8 (from -r requirements.txt (line 18))
2018-02-19T20:47:30.931069+00:00 app[web.1]: 20:47:30 python.1 |   Downloading Jinja2-2.8-py2.py3-none-any.whl (263kB)
2018-02-19T20:47:31.351463+00:00 app[web.1]: 20:47:31 python.1 | Collecting mock==1.3.0 (from -r requirements.txt (line 19))
2018-02-19T20:47:31.417121+00:00 app[web.1]: 20:47:31 python.1 |   Downloading mock-1.3.0-py2.py3-none-any.whl (56kB)
2018-02-19T20:47:31.551120+00:00 app[web.1]: 20:47:31 python.1 | Collecting nose==1.3.7 (from -r requirements.txt (line 20))
2018-02-19T20:47:31.583208+00:00 app[web.1]: 20:47:31 python.1 |   Downloading nose-1.3.7-py3-none-any.whl (154kB)
2018-02-19T20:47:31.695664+00:00 app[web.1]: 20:47:31 python.1 | Collecting psycopg2==2.6.1 (from -r requirements.txt (line 21))
2018-02-19T20:47:31.845991+00:00 app[web.1]: 20:47:31 python.1 |   Downloading psycopg2-2.6.1.tar.gz (371kB)
2018-02-19T20:47:32.566497+00:00 app[web.1]: 20:47:32 python.1 |     Complete output from command python setup.py egg_info:
2018-02-19T20:47:32.566764+00:00 app[web.1]: 20:47:32 python.1 |     running egg_info
2018-02-19T20:47:32.566971+00:00 app[web.1]: 20:47:32 python.1 |     creating pip-egg-info/psycopg2.egg-info
2018-02-19T20:47:32.567176+00:00 app[web.1]: 20:47:32 python.1 |     writing pip-egg-info/psycopg2.egg-info/PKG-INFO
2018-02-19T20:47:32.567384+00:00 app[web.1]: 20:47:32 python.1 |     writing dependency_links to pip-egg-info/psycopg2.egg-info/dependency_links.txt
2018-02-19T20:47:32.567582+00:00 app[web.1]: 20:47:32 python.1 |     writing top-level names to pip-egg-info/psycopg2.egg-info/top_level.txt
2018-02-19T20:47:32.567779+00:00 app[web.1]: 20:47:32 python.1 |     writing manifest file 'pip-egg-info/psycopg2.egg-info/SOURCES.txt'
2018-02-19T20:47:32.567971+00:00 app[web.1]: 20:47:32 python.1 |     Error: pg_config executable not found.
2018-02-19T20:47:32.568163+00:00 app[web.1]: 20:47:32 python.1 |     
2018-02-19T20:47:32.568368+00:00 app[web.1]: 20:47:32 python.1 |     Please add the directory containing pg_config to the PATH
2018-02-19T20:47:32.568564+00:00 app[web.1]: 20:47:32 python.1 |     or specify the full executable path with the option:
2018-02-19T20:47:32.568762+00:00 app[web.1]: 20:47:32 python.1 |     
2018-02-19T20:47:32.569004+00:00 app[web.1]: 20:47:32 python.1 |         python setup.py build_ext --pg-config /path/to/pg_config build ...
2018-02-19T20:47:32.569202+00:00 app[web.1]: 20:47:32 python.1 |     
2018-02-19T20:47:32.569395+00:00 app[web.1]: 20:47:32 python.1 |     or with the pg_config option in 'setup.cfg'.
2018-02-19T20:47:32.569670+00:00 app[web.1]: 20:47:32 python.1 |     
2018-02-19T20:47:32.569862+00:00 app[web.1]: 20:47:32 python.1 |     ----------------------------------------
2018-02-19T20:47:33.178067+00:00 app[web.1]: 20:47:33 python.1 | Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-cq2qoene/psycopg2/
2018-02-19T20:47:33.374849+00:00 app[web.1]: 20:47:33 system   | python.1 stopped (rc=1)

When I run pip install requirements.txt from my Procfile

Don't do this in your Procfile .

As long as Heroku knows your app is a Python app (either through detection when it sees a requirements.txt or Pipfile or by explicit configuration ) it will install your dependencies automatically .

A Procfile for a simple application might just contain a web process defining your application, eg

web: gunicorn myapp.wsgi

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM