John Jones
John Jones

Reputation: 11

Heroku not installing packages on deploy from requirements.txt

I'm trying to deploy a heroku app that uses python, and have a list of dependencies in my requirements.txt file that lives in my project root.

beautifulsoup4==4.12.2 
blinker==1.8.2 
certifi==2023.5.7 
charset-normalizer==3.1.0 
click==8.1.7     
DateTime==5.5 
distlib==0.3.8 
et-xmlfile==1.1.0 
filelock==3.15.3 
flask==3.0.3 
flask-Admin==1.6.1 
flask-Cors==4.0.1 
flask-SQLAlchemy==3.1.1 
greenlet==3.0.3 
gunicorn==22.0.0 
idna==3.4 
itsdangerous==2.2.0 
Jinja2==3.1.4 
MarkupSafe==2.1.5 
numpy==1.26.4 
oauthlib==3.2.2 
openpyxl==3.1.2 
packaging==24.1 
pandas==2.2.2 
pipenv==2024.0.1 
platformdirs==4.2.2 
psycopg2-binary==2.9.9 
python-dateutil==2.9.0.post0 
pytz==2024.1 
requests==2.31.0 
requests-oauthlib==1.3.1 
six==1.16.0 
soupsieve==2.4.1 
SQLAlchemy==2.0.31 
tweepy==4.14.0 
typing_extensions==4.12.2 
tzdata==2024.1 
urllib3==2.0.3 
virtualenv==20.26.2 
Werkzeug==3.0.3 
WTForms==3.1.2 
zope.interface==6.3

Yet when I deploy, the build succeeds, but I consistently get the following error.

2024-06-23T18:41:51.113217+00:00 heroku[web.1]: Starting process with command `gunicorn app:app --bind 0.0.0.0:51887`
2024-06-23T18:41:51.883942+00:00 app[web.1]: Python buildpack: Detected 512 MB available memory and 8 CPU cores.
2024-06-23T18:41:51.884131+00:00 app[web.1]: Python buildpack: Defaulting WEB_CONCURRENCY to 2 based on the available memory.
2024-06-23T18:41:52.012827+00:00 app[web.1]: [2024-06-23 18:41:52 +0000] [2] [INFO] Starting gunicorn 22.0.0
2024-06-23T18:41:52.013134+00:00 app[web.1]: [2024-06-23 18:41:52 +0000] [2] [INFO] Listening at: http://0.0.0.0:51887 (2)
2024-06-23T18:41:52.013180+00:00 app[web.1]: [2024-06-23 18:41:52 +0000] [2] [INFO] Using worker: sync
2024-06-23T18:41:52.015233+00:00 app[web.1]: [2024-06-23 18:41:52 +0000] [9] [INFO] Booting worker with pid: 9
2024-06-23T18:41:52.019169+00:00 app[web.1]: [2024-06-23 18:41:52 +0000] [9] [ERROR] Exception in worker process
2024-06-23T18:41:52.019171+00:00 app[web.1]: Traceback (most recent call last):
2024-06-23T18:41:52.019171+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.12/site-packages/gunicorn/arbiter.py", line 609, in spawn_worker
2024-06-23T18:41:52.019172+00:00 app[web.1]: worker.init_process()
2024-06-23T18:41:52.019172+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.12/site-packages/gunicorn/workers/base.py", line 134, in init_process
2024-06-23T18:41:52.019173+00:00 app[web.1]: self.load_wsgi()
2024-06-23T18:41:52.019173+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.12/site-packages/gunicorn/workers/base.py", line 146, in load_wsgi
2024-06-23T18:41:52.019173+00:00 app[web.1]: self.wsgi = self.app.wsgi()
2024-06-23T18:41:52.019173+00:00 app[web.1]: ^^^^^^^^^^^^^^^
2024-06-23T18:41:52.019174+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.12/site-packages/gunicorn/app/base.py", line 67, in wsgi
2024-06-23T18:41:52.019174+00:00 app[web.1]: self.callable = self.load()
2024-06-23T18:41:52.019174+00:00 app[web.1]: ^^^^^^^^^^^
2024-06-23T18:41:52.019175+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.12/site-packages/gunicorn/app/wsgiapp.py", line 58, in load
2024-06-23T18:41:52.019175+00:00 app[web.1]: return self.load_wsgiapp()
2024-06-23T18:41:52.019175+00:00 app[web.1]: ^^^^^^^^^^^^^^^^^^^
2024-06-23T18:41:52.019175+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.12/site-packages/gunicorn/app/wsgiapp.py", line 48, in load_wsgiapp
2024-06-23T18:41:52.019175+00:00 app[web.1]: return util.import_app(self.app_uri)
2024-06-23T18:41:52.019176+00:00 app[web.1]: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2024-06-23T18:41:52.019176+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.12/site-packages/gunicorn/util.py", line 371, in import_app
2024-06-23T18:41:52.019176+00:00 app[web.1]: mod = importlib.import_module(module)
2024-06-23T18:41:52.019176+00:00 app[web.1]: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2024-06-23T18:41:52.019177+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.12/importlib/__init__.py", line 90, in import_module
2024-06-23T18:41:52.019177+00:00 app[web.1]: return _bootstrap._gcd_import(name[level:], package, level)
2024-06-23T18:41:52.019177+00:00 app[web.1]: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2024-06-23T18:41:52.019177+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 1387, in _gcd_import
2024-06-23T18:41:52.019178+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
2024-06-23T18:41:52.019178+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 1331, in _find_and_load_unlocked
2024-06-23T18:41:52.019178+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 935, in _load_unlocked
2024-06-23T18:41:52.019178+00:00 app[web.1]: File "<frozen importlib._bootstrap_external>", line 995, in exec_module
2024-06-23T18:41:52.019178+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
2024-06-23T18:41:52.019179+00:00 app[web.1]: File "/app/app.py", line 1, in <module>
2024-06-23T18:41:52.019179+00:00 app[web.1]: from flask import Flask
2024-06-23T18:41:52.019179+00:00 app[web.1]: ModuleNotFoundError: No module named 'flask'

Where it cannot find flask. I confirmed that this is the case as I used the heroku cli to take a look at packages, and I only have the following installed there.

certifi      2024.6.2
distlib      0.3.8
filelock     3.15.4
gunicorn     22.0.0
packaging    24.1
pip          24.0
pipenv       2023.12.1
platformdirs 4.2.2
setuptools   69.2.0
virtualenv   20.26.3
wheel        0.43.0

My file structure looks like this

toplevelfolder
-->__init__.py
-->app.py
-->(other files here)

Pipfile structure is this:

[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"

[packages]
gunicorn = "*"

[dev-packages]

[requires]
python_version = "3.8"

And I am using relative imports for any of my internal files I am importing.

This question has been asked before here but the only suggestions were to recreate the project as it appeared to be a heroku bug. Heroku not reading requirement.txt file Since it was from 6 years ago I assumed it had been fixed, but maybe not? I have tried everything in that app with no luck

I attempted to uninstall flask, and reinstall it, with no luck. I also cleared my requirements file, pushed it up, and then pushed it up with every dependency to make sure they were installed with no luck.

Upvotes: 1

Views: 49

Answers (0)

Related Questions