ModuleNotFoundError: No module named 'pkg_resources' Django Deploy

Hello, I’m getting this error when I try to deploy my Django App, looks something about simplejwt library, but I’m not sure about why. Maybe is about the ‘Removing setuptools (65.3.0)’ when starts to deploy

Sep 17 09:11:34 PM Traceback (most recent call last):
Sep 17 09:11:34 PM File “/opt/render/project/src/manage.py”, line 22, in
Sep 17 09:11:34 PM main()
Sep 17 09:11:34 PM File “/opt/render/project/src/manage.py”, line 18, in main
Sep 17 09:11:34 PM execute_from_command_line(sys.argv)
Sep 17 09:11:34 PM File “/opt/render/project/src/.venv/lib/python3.9/site-packages/django/core/management/init.py”, line 446, in execute_from_command_line
Sep 17 09:11:34 PM utility.execute()
Sep 17 09:11:34 PM File “/opt/render/project/src/.venv/lib/python3.9/site-packages/django/core/management/init.py”, line 420, in execute
Sep 17 09:11:34 PM django.setup()
Sep 17 09:11:34 PM File “/opt/render/project/src/.venv/lib/python3.9/site-packages/django/init.py”, line 24, in setup
Sep 17 09:11:34 PM apps.populate(settings.INSTALLED_APPS)
Sep 17 09:11:34 PM File “/opt/render/project/src/.venv/lib/python3.9/site-packages/django/apps/registry.py”, line 91, in populate
Sep 17 09:11:34 PM app_config = AppConfig.create(entry)
Sep 17 09:11:34 PM File “/opt/render/project/src/.venv/lib/python3.9/site-packages/django/apps/config.py”, line 193, in create
Sep 17 09:11:34 PM import_module(entry)
Sep 17 09:11:34 PM File “/opt/render/project/python/Python-3.9.14/lib/python3.9/importlib/init.py”, line 127, in import_module
Sep 17 09:11:34 PM return _bootstrap._gcd_import(name[level:], package, level)
Sep 17 09:11:34 PM File “”, line 1030, in _gcd_import
Sep 17 09:11:34 PM File “”, line 1007, in _find_and_load
Sep 17 09:11:34 PM File “”, line 972, in _find_and_load_unlocked
Sep 17 09:11:34 PM File “”, line 228, in _call_with_frames_removed
Sep 17 09:11:34 PM File “”, line 1030, in _gcd_import
Sep 17 09:11:34 PM File “”, line 1007, in _find_and_load
Sep 17 09:11:34 PM File “”, line 986, in _find_and_load_unlocked
Sep 17 09:11:34 PM File “”, line 680, in _load_unlocked
Sep 17 09:11:34 PM File “”, line 850, in exec_module
Sep 17 09:11:34 PM File “”, line 228, in _call_with_frames_removed
Sep 17 09:11:34 PM File “/opt/render/project/src/.venv/lib/python3.9/site-packages/rest_framework_simplejwt/init.py”, line 1, in
Sep 17 09:11:34 PM from pkg_resources import DistributionNotFound, get_distribution
Sep 17 09:11:34 PM ModuleNotFoundError: No module named ‘pkg_resources’

this is my pyproject.toml

[tool.poetry]
name = “poetry-calendar-api”
version = “0.1.0”
description = “”
authors = [“”]
readme = “README.md”
packages = [{include = “poetry_calendar_api”}]

[tool.poetry.dependencies]
python = “^3.8”
Django = “^4.1.1”
djangorestframework = “^3.13.1”
asgiref = “^3.5.2”
django-cors-headers = “^3.13.0”
djangorestframework-simplejwt = “^5.2.0”
PyJWT = “^2.5.0”
pytz = “^2022.2.1”
sqlparse = “^0.4.2”
tzdata = “^2022.2”
dj-database-url = “^1.0.0”
psycopg2-binary = “^2.9.3”
whitenoise = {extras = [“brotli”], version = “^6.2.0”}
gunicorn = “^20.1.0”
setuptools = “^65.3.0”
distribute = “^0.7.3”

[build-system]
requires = [“setuptools”, “poetry-core”]
build-backend = “poetry.core.masonry.api”

I try to add setuptools as required but nothing change

Hey there,
Did you get this figured out? I’ve seen other customers solving this using as build script which performs:

pip install --upgrade pippip install --force-reinstall -U setuptools

John B

1 Like

I add this in the build.sh and works perfectly! thanksss

almost same problem here

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