Search code examples
pythonherokuflask-wtformsheroku-toolbelt

FLASK Python Heroku deployment issues


I am trying to deploy an app to heroku, its a very simple app, however when i try to deploy using push heroku master i get the following errors

(env) PS C:\Users\xblade\Desktop\F1> git push heroku master
Counting objects: 3, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 465 bytes | 0 bytes/s, done.
Total 3 (delta 1), reused 0 (delta 0)
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> Python app detected
remote: -----> Installing pip
remote: -----> Installing requirements with pip
remote:        Collecting click==6.7 (from -r /tmp/build_351795e51ca44a70ac39d32b8fa95475/requirements.txt (line 1))
remote:          Downloading click-6.7-py2.py3-none-any.whl (71kB)
remote:        Collecting Flask==0.12.2 (from -r /tmp/build_351795e51ca44a70ac39d32b8fa95475/requirements.txt (line 2))
remote:          Downloading Flask-0.12.2-py2.py3-none-any.whl (83kB)
remote:        Collecting Flask-SQLAlchemy==2.3.2 (from -r /tmp/build_351795e51ca44a70ac39d32b8fa95475/requirements.txt (line 3))
remote:          Downloading Flask_SQLAlchemy-2.3.2-py2.py3-none-any.whl
remote:        Collecting Flask-WTF==0.14.2 (from -r /tmp/build_351795e51ca44a70ac39d32b8fa95475/requirements.txt (line 4))
remote:          Downloading Flask_WTF-0.14.2-py2.py3-none-any.whl
remote:        Collecting itsdangerous==0.24 (from -r /tmp/build_351795e51ca44a70ac39d32b8fa95475/requirements.txt (line 6))
remote:          Downloading itsdangerous-0.24.tar.gz (46kB)
remote:            Complete output from command python setup.py egg_info:
remote:            /app/.heroku/python/lib/python3.6/distutils/dist.py:261: UserWarning: Unknown distribution option: 'zip_safe'
remote:              warnings.warn(msg)
remote:            usage: -c [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
remote:               or: -c --help [cmd1 cmd2 ...]
remote:               or: -c --help-commands
remote:               or: -c cmd --help
remote:
remote:            error: invalid command 'egg_info'
remote:
remote:            ----------------------------------------
remote:        Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-huroui6_/itsdangerous/
remote:  !     Push rejected, failed to compile Python app.
remote:
remote:  !     Push failed
remote: Verifying deploy....
remote:
remote: !       Push rejected to boiling-crag-24883.
remote:
To https://git.heroku.com/boiling-crag-24883.git
 ! [remote rejected] master -> master (pre-receive hook declined)

It seems to be something with the requirements.txt.

Its trying to install some of the pip requirements but it fails.

I think it has something to do with distutils. I tried to upload without any requirements except 1 and it works fine (but app does not function).

The issue seems to be with flask packages and their additional packages such as itsdangerous.

here is the list of packages in the requirements.txt

click==6.7
Flask==0.12.2
Flask-SQLAlchemy==2.3.2
Flask-WTF==0.14.2
gunicorn==19.7.1
itsdangerous==0.24
Jinja2==2.10
MarkupSafe==1.0
psycopg2==2.7.4
SQLAlchemy==1.2.5
Werkzeug==0.14.1
WTForms==2.1

Does anyone know why this deployment is failing and what i can do to fix it?

Thanks


Solution

  • I found a better solution here, you can solve this issue using the following two commands in your command line

    $ heroku plugins:install heroku-repo
    $ heroku repo:purge_cache
    

    please find the link to the solution here https://github.com/heroku/heroku-buildpack-python/issues/661#issuecomment-374183119