Search code examples
saleor

Saleor Can't Find SECRET_KEY Even Though Python Can Find It


When trying to launch Saleor, the following error appears saying that it can't find SECRET_KEY

Stack:

Debian

Python 3.7.4

Saleor (latest as of 7-25-19)

:/$ sudo python manage.py migrate

Traceback (most recent call last): File "manage.py", line 10, in execute_from_command_line(sys.argv)

... ...

File "/usr/local/lib/python3.7/site-packages/django/conf/init.py", line 178, in init raise ImproperlyConfigured("The SECRET_KEY setting must not be empty.") django.core.exceptions.ImproperlyConfigured: The SECRET_KEY setting must not be empty.

I have done

:/$ env

and see

SECRET_KEY=the-secret-key

I also entered a python prompt and tried

>>> import os

>>> print(os.environ.get("SECRET_KEY"))

the-secret-key

So the value appears to be set an accessible, but the system can't seem to find it.


Solution

  • Try sudo -E python manage.py migrate

    The -E flag preserves environment variables with sudo.