'Django deployment on heroku throwing ModuleNotFoundError at / No module named 'pandas'
I have pandas and numpy installed in my pipenv and have checked that my requirements.txt is up to date and everything is installed. The app works fine on localhost but when it deploys my browser throws:
ModuleNotFoundError at /
No module named 'pandas'
Request Method: GET
Request URL: https://game-recs.herokuapp.com/
Django Version: 4.0.3
Exception Type: ModuleNotFoundError
Exception Value:
No module named 'pandas'
Exception Location: /app/recommender/algorithm/code.py, line 1, in <module>
Python Executable: /app/.heroku/python/bin/python
Python Version: 3.10.2
Python Path:
['/app',
'/app/.heroku/python/bin',
'/usr/bin/python',
'/app/.heroku/python/lib/python310.zip',
'/app/.heroku/python/lib/python3.10',
'/app/.heroku/python/lib/python3.10/lib-dynload',
'/app/.heroku/python/lib/python3.10/site-packages']
All the other modules work fine... could this be a path issue? The project was deploying well until I added in a python file importing pandas.
requirements.txt
asgiref==3.5.0
backports.zoneinfo==0.2.1
dj-database-url==0.5.0
Django==4.0.3
gunicorn==20.1.0
numpy==1.22.3
pandas==1.4.1
psycopg2==2.9.3
psycopg2-binary==2.9.3
python-dateutil==2.8.2
pytz==2021.3
six==1.16.0
sqlparse==0.4.2
waitress==2.1.0
whitenoise==6.0.0
Heroku build logs (no error until I try to view the site)
2022-03-13T19:35:31.010043+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
2022-03-13T19:35:31.010043+00:00 app[web.1]: File "/app/gamerecs/urls.py", line 25, in <module>
2022-03-13T19:35:31.010043+00:00 app[web.1]: from recommender.views import (
2022-03-13T19:35:31.010043+00:00 app[web.1]: File "/app/recommender/views.py", line 12, in <module>
2022-03-13T19:35:31.010044+00:00 app[web.1]: from .algorithm.code import getRec
2022-03-13T19:35:31.010044+00:00 app[web.1]: File "/app/recommender/algorithm/code.py", line 1, in <module>
2022-03-13T19:35:31.010044+00:00 app[web.1]: import pandas as pd
2022-03-13T19:35:31.010045+00:00 app[web.1]: ModuleNotFoundError: No module named 'pandas'
2022-03-13T19:35:31.010939+00:00 app[web.1]: 10.1.49.237 - - [13/Mar/2022:19:35:31 +0000] "GET / HTTP/1.1" 500 133097 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.51 Safari/537.36"
2022-03-13T19:35:31.029713+00:00 heroku[router]: at=info method=GET path="/" host=game-recs.herokuapp.com request_id=51f8b207-7692-4f58-85eb-6febe1a2e1d2 fwd="174.76.8.15" dyno=web.1 connect=0ms service=106ms status=500 bytes=133399 protocol=https
pipfile
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"
[packages]
django = "*"
gunicorn = "*"
[dev-packages]
[requires]
python_version = "3.8"
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
