EnvError during Heroku push

I added my gmail password to my .env file located in the root directory of my django project. Why is heroku raising an Env error when I push, is there something else I haven't done?

My settings.py file import:

from pathlib import Path
from environs import Env
env = Env()

my .env file:

SECRET_KEY = Secretkeyyy

my refence to the .env email variable in my settings.py:


the error during heroku push:

(.venv) PS C:\Users\user\Desktop\DJANGO_PROJECTS\diary_app> git push heroku HEAD:main
Enumerating objects: 345, done.
Counting objects: 100% (345/345), done.
Delta compression using up to 4 threads
Compressing objects: 100% (337/337), done.
Writing objects: 100% (345/345), 1007.91 KiB | 79.00 KiB/s, done.
Total 345 (delta 48), reused 0 (delta 0), pack-reused 0
remote: Compressing source files... done.
remote: Building source:
remote: -----> Building on the Heroku-22 stack
remote: -----> Using buildpack: heroku/python
remote: -----> Python app detected
remote: -----> Using Python version specified in runtime.txt
remote: -----> Installing python-3.10.7
remote: -----> Installing pip 22.2.2, setuptools 63.4.3 and wheel 0.37.1
remote: -----> Installing SQLite3
remote: -----> Installing requirements with pip
remote:        Collecting asgiref==3.5.2
remote:          Downloading asgiref-3.5.2-py3-none-any.whl (22 kB)
remote:        Collecting black==22.8.0
remote:          Downloading black-22.8.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.5 MB)
remote:        Collecting click==8.1.3
remote:          Downloading click-8.1.3-py3-none-any.whl (96 kB)
remote:        Collecting colorama==0.4.5
remote:          Downloading colorama-0.4.5-py2.py3-none-any.whl (16 kB)
remote:        Collecting crispy-bootstrap5==0.6
remote:          Downloading crispy_bootstrap5-0.6-py3-none-any.whl (22 kB)
remote:        Collecting dj-database-url==1.0.0
remote:          Downloading dj_database_url-1.0.0-py3-none-any.whl (6.6 kB)
remote:        Collecting dj-email-url==1.0.5
remote:          Downloading dj_email_url-1.0.5-py2.py3-none-any.whl (6.9 kB)
remote:        Collecting Django==4.1.1
remote:          Downloading Django-4.1.1-py3-none-any.whl (8.1 MB)
remote:        Collecting django-cache-url==3.4.2
remote:          Downloading django_cache_url-3.4.2-py2.py3-none-any.whl (4.7 kB)
remote:        Collecting django-crispy-forms==1.14.0
remote:          Downloading django_crispy_forms-1.14.0-py3-none-any.whl (133 kB)
remote:        Collecting environs==9.5.0
remote:          Downloading environs-9.5.0-py2.py3-none-any.whl (12 kB)
remote:        Collecting gunicorn==20.1.0
remote:          Downloading gunicorn-20.1.0-py3-none-any.whl (79 kB)
remote:        Collecting marshmallow==3.18.0
remote:          Downloading marshmallow-3.18.0-py3-none-any.whl (48 kB)
remote:        Collecting mypy-extensions==0.4.3
remote:          Downloading mypy_extensions-0.4.3-py2.py3-none-any.whl (4.5 kB)
remote:        Collecting packaging==21.3
remote:          Downloading packaging-21.3-py3-none-any.whl (40 kB)
remote:        Collecting pathspec==0.10.1
remote:          Downloading pathspec-0.10.1-py3-none-any.whl (27 kB)
remote:        Collecting platformdirs==2.5.2
remote:          Downloading platformdirs-2.5.2-py3-none-any.whl (14 kB)
remote:        Collecting psycopg2==2.9.3
remote:          Downloading psycopg2-2.9.3.tar.gz (380 kB)
remote:          Preparing metadata (setup.py): started
remote:          Preparing metadata (setup.py): finished with status 'done'
remote:        Collecting pyparsing==3.0.9
remote:          Downloading pyparsing-3.0.9-py3-none-any.whl (98 kB)
remote:        Collecting python-dotenv==0.21.0
remote:          Downloading python_dotenv-0.21.0-py3-none-any.whl (18 kB)
remote:        Collecting sqlparse==0.4.2
remote:          Downloading sqlparse-0.4.2-py3-none-any.whl (42 kB)
remote:        Collecting tomli==2.0.1
remote:          Downloading tomli-2.0.1-py3-none-any.whl (12 kB)
remote:        Collecting tzdata==2022.2
remote:          Downloading tzdata-2022.2-py2.py3-none-any.whl (336 kB)
remote:        Collecting whitenoise==6.2.0
remote:          Downloading whitenoise-6.2.0-py3-none-any.whl (19 kB)
remote:        Building wheels for collected packages: psycopg2
remote:          Building wheel for psycopg2 (setup.py): started
remote:          Building wheel for psycopg2 (setup.py): finished with status 'done'
remote:          Created wheel for psycopg2: filename=psycopg2-2.9.3-cp310-cp310-linux_x86_64.whl size=159237 sha256=278cc36886fa6fe99e243b273ff28fb167d85bc9a9db74c27a8bd3932ca30af0
remote:          Stored in directory: /tmp/pip-ephem-wheel-cache-eec7jxpm/wheels/81/b6/3d/091aad3e8919ea76c84c2674b02ce3ab52de882e091c39249e
remote:        Successfully built psycopg2
remote:        Installing collected packages: mypy-extensions, django-cache-url, dj-email-url, whitenoise, tzdata, tomli, sqlparse, python-dotenv, pyparsing, psycopg2, platformdirs, pathspec, gunicorn, django-crispy-forms, colorama, click, asgiref, packaging, Django, black, marshmallow, dj-database-url, crispy-bootstrap5, environs
remote:        Successfully installed Django-4.1.1 asgiref-3.5.2 black-22.8.0 click-8.1.3 colorama-0.4.5 crispy-bootstrap5-0.6 dj-database-url-1.0.0 dj-email-url-1.0.5 django-cache-url-3.4.2 django-crispy-forms-1.14.0 environs-9.5.0 gunicorn-20.1.0 marshmallow-3.18.0 mypy-extensions-0.4.3 packaging-21.3 pathspec-0.10.1 platformdirs-2.5.2 psycopg2-2.9.3 pyparsing-3.0.9 python-dotenv-0.21.0 sqlparse-0.4.2 tomli-2.0.1 tzdata-2022.2 whitenoise-6.2.0
remote: -----> $ python manage.py collectstatic --noinput
remote:        Traceback (most recent call last):
remote:          File "/tmp/build_87dc09f9/manage.py", line 22, in <module>
remote:            main()
remote:          File "/tmp/build_87dc09f9/manage.py", line 18, in main
remote:            execute_from_command_line(sys.argv)
remote:          File "/app/.heroku/python/lib/python3.10/site-packages/django/core/management/__init__.py", line 446, in execute_from_command_line
remote:            utility.execute()
remote:          File "/app/.heroku/python/lib/python3.10/site-packages/django/core/management/__init__.py", line 386, in execute
remote:            settings.INSTALLED_APPS
remote:          File "/app/.heroku/python/lib/python3.10/site-packages/django/conf/__init__.py", line 92, in __getattr__
remote:            self._setup(name)
remote:          File "/app/.heroku/python/lib/python3.10/site-packages/django/conf/__init__.py", line 79, in _setup
remote:            self._wrapped = Settings(settings_module)
remote:          File "/app/.heroku/python/lib/python3.10/site-packages/django/conf/__init__.py", line 190, in __init__
remote:            mod = importlib.import_module(self.SETTINGS_MODULE)
remote:          File "/app/.heroku/python/lib/python3.10/importlib/__init__.py", line 126, in import_module
remote:            return _bootstrap._gcd_import(name[level:], package, level)
remote:          File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
remote:          File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
remote:          File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
remote:          File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
remote:          File "<frozen importlib._bootstrap_external>", line 883, in exec_module
remote:          File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
remote:          File "/tmp/build_87dc09f9/diary_project/settings.py", line 154, in <module>
remote:            EMAIL_HOST_PASSWORD = env.str("EMAIL_HOST_PASSWORD")
remote:          File "/app/.heroku/python/lib/python3.10/site-packages/environs/__init__.py", line 116, in method
remote:            raise EnvError('Environment variable "{}" not set'.format(proxied_key or parsed_key))
remote:        environs.EnvError: Environment variable "EMAIL_HOST_PASSWORD" not set
remote:  !     Error while running '$ python manage.py collectstatic --noinput'.
remote:        See traceback above for details.
remote:        You may need to update application code to resolve this error.
remote:        Or, you can disable collectstatic for this application:
remote:           $ heroku config:set DISABLE_COLLECTSTATIC=1
remote:        https://devcenter.heroku.com/articles/django-assets
remote:  !     Push rejected, failed to compile Python app.
remote:  !     Push failed
remote: Verifying deploy....
remote: !       Push rejected to diary--web--app.
To https://git.heroku.com/diary--web--app.git
 ! [remote rejected] HEAD -> main (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/diary--web--app.git'

Is there something I am doing wrong?

Back to Top