Blomblomski
Blomblomski

Reputation: 21

Failed pushing Python Flask App to Heroku

New to Flask and deploying on Heroku, trying to push to Heroku and I get this error when installing dependencies:

The pipenv version looks funny not sure if that is correct or how to correct it if that is the error

Enumerating objects: 38, done.
Counting objects: 100% (38/38), done.
Delta compression using up to 8 threads
Compressing objects: 100% (30/30), done.
Writing objects: 100% (38/38), 83.94 KiB | 10.49 MiB/s, done.
Total 38 (delta 8), reused 0 (delta 0), pack-reused 0
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> Python app detected
remote: -----> Installing python-3.8.5
remote: -----> Installing pip
remote: -----> Installing dependencies with Pipenv 2018.5.18
remote:        Traceback (most recent call last):
remote:          File "/tmp/build_9fedd330/.heroku/python/lib/python3.8/site-packages/pipenv/patched/prettytoml/elements/abstracttable.py", line 27, in _enumerate_items
remote:            yield next(non_metadata), next(non_metadata)
remote:        StopIteration
remote:
remote:            return toml.loads(contents)
remote:          File "/tmp/build_9fedd330/.heroku/python/lib/python3.8/site-packages/pipenv/vendor/toml.py", line 307, in loads
remote:            raise TomlDecodeError("Key group not on a line by itself.")
remote:        toml.TomlDecodeError: Key group not on a line by itself.
remote:  !     Push rejected, failed to compile Python app.
remote:
remote:  !     Push failed
remote: Verifying deploy...
remote:

Not sure what the error is! Any help would be appreciated. I have removed some of the error list due to asking me for more details as to much code

Upvotes: 0

Views: 294

Answers (1)

Nikita Zavyalov
Nikita Zavyalov

Reputation: 96

If you have not yet done it, create a file with dependencies for your code and specify versions explicitly (example):

Flask==0.8
Jinja2==2.6
Werkzeug==0.8.3
certifi==0.0.8
chardet==1.0.1
distribute==0.6.24
gunicorn==0.14.2
requests==0.11.1 

Then (if you didn't create it yet), set up a new virtual environment, install all the requirements and check that your code is running by using the python from this environment.

  1. Install virtualenv: python3 -m pip install --user virtualenv

  2. Create a virtual environment: python3 -m venv env

  3. Activate the virtual environment source env/bin/activate

  4. Install all the requirements pip install -r requirements.txt

  5. Run your application in the same console where you activated the virtual environment.

The Heroku uses the following command for installing dependencies pip install -r requirements.txt. So if it gives you error on your local machine you would know what's the problem.

Upvotes: 1

Related Questions