Santiago
Santiago

Reputation: 125

Deploy django app in heroku with poetry environment

I've been using poetry for a while for many practice projects but haven't deployed anything until now, and when I try to do it in heroku I get this error.

-----> Installing python-3.9.1
-----> Installing pip 20.2.4, setuptools 47.1.1 and wheel 0.36.2
-----> Installing SQLite3
-----> Installing requirements with pip
       Processing /home/santi/.cache/pypoetry/artifacts/9c/90/26/d9fa1dfd567d8ba46faa44b741eb6442f3b97eb9f10a40bc1ad7a7f10e/asgiref-3.3.1-py3-none-any.whl
       ERROR: Could not install packages due to an EnvironmentError: [Errno 2] No such file or directory: '/home/santi/.cache/pypoetry/artifacts/9c/90/26/d9fa1dfd567d8ba46faa44b741eb6442f3b97eb9f10a40bc1ad7a7f10e/asgiref-3.3.1-py3-none-any.whl'
       
 !     Push rejected, failed to compile Python app.
 !     Push failed

I can't seem to find anything specific to this django-poetry-heroku issue so maybe I can find some help over here, I have my petry.lock and .toml files, also a requirements.txt since heroku requires it, here they are...

pyproject.toml
[tool.poetry]
name = "Team Wool Capstone App"
version = "0.1.0"
description = "News app with likes, and user submission feature"
authors = ["Joseph Dubon <[email protected]>"]

[tool.poetry.dependencies]
python = "^3.9"
Django = "^3.1.7"
flake8 = "^3.9.0"
Pillow = "^8.2.0"
whitenoise = "^5.2.0"
django-environ = "^0.4.5"
gunicorn = "^20.1.0"

[tool.poetry.dev-dependencies]

[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"

Upvotes: 1

Views: 1978

Answers (2)

claudius
claudius

Reputation: 1005

The Heroku platform yet does not run with Poetry.

To deploy your Django application you'll need to use the Pip, Pip3, or Pipenv tools.
To use Pip/Pip3 you need to export your pyproject.toml file to a requirements.txt file.

The Poetry has a command for this, which is (see the docs on Poetry):

poetry export -f requirements.txt --output requirements.txt

Upvotes: 1

Ryan F
Ryan F

Reputation: 128

Are you using the heroku buildpack for poetry? Heroku only reads requirements.txt files when building python projects, and you will need to set multiple config vars and explicitly tell heroku to use the poetry buildpack.

heroku buildpacks:clear
heroku buildpacks:add https://github.com/moneymeets/python-poetry-buildpack.git
heroku buildpacks:add heroku/python

Check this link out to see more explicit directions

Upvotes: 4

Related Questions