Tutorial deploy failure

Thanks for your help so far, my Render buddies.

I have a new error when deploying the Django tutorial app.

Sep 29 11:42:13 AM  ==> Starting service with 'gunicorn www.wsgi:application'
Sep 29 11:42:14 AM  Traceback (most recent call last):
Sep 29 11:42:14 AM    File "/opt/render/project/src/.venv/bin/gunicorn", line 5, in <module>
Sep 29 11:42:14 AM      from gunicorn.app.wsgiapp import run
Sep 29 11:42:14 AM    File "/opt/render/project/src/.venv/lib/python3.10/site-packages/gunicorn/app/wsgiapp.py", line 9, in <module>
Sep 29 11:42:14 AM      from gunicorn.app.base import Application
Sep 29 11:42:14 AM    File "/opt/render/project/src/.venv/lib/python3.10/site-packages/gunicorn/app/base.py", line 11, in <module>
Sep 29 11:42:14 AM      from gunicorn import util
Sep 29 11:42:14 AM    File "/opt/render/project/src/.venv/lib/python3.10/site-packages/gunicorn/util.py", line 25, in <module>
Sep 29 11:42:14 AM      import pkg_resources
Sep 29 11:42:14 AM  ModuleNotFoundError: No module named 'pkg_resources'

I had this problem before, and in trying to resolve it, I had the other two error pop up.

Any ideas?

Hi Micah,

Thanks for reaching out.

I’m not a Python expert, but a quick search for ModuleNotFoundError: No module named 'pkg_resources' seems to show pkg_resources is related to setuptools.

There’s also another Community post here with the same issue (and a solution) https://community.render.com/t/modulenotfounderror-no-module-named-pkg-resources-django-deploy

Hope that helps

Alan

Thanks, that worked.

The tutorial build.sh:

#!/usr/bin/env bash
# exit on error
set -o errexit


poetry install

python manage.py collectstatic --no-input
python manage.py migrate

The working build script:

#!/usr/bin/env bash
# exit on error
set -o errexit


poetry install
pip install --upgrade pip
pip install --force-reinstall -U setuptools
python manage.py collectstatic --no-input
python manage.py migrate

The reinstall of setuptools comes after the poetry install step.

This solved the issue for me as well!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.