【问题标题】:python manage.py runserver error environment variable [closed]python manage.py runserver错误环境变量[关闭]
【发布时间】:2016-09-01 14:36:18
【问题描述】:

我尝试运行这个。我正在学习 django 但这显示错误..请帮助。

Kaustubhs-MacBook-Pro-2:crmeasy kaustubhmundra$ python manage.py runserver
Traceback (most recent call last):
  File "manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/Library/Python/2.7/site-packages/django/core/management/__init__.py", line 367, in execute_from_command_line
    utility.execute()
  File "/Library/Python/2.7/site-packages/django/core/management/__init__.py", line 359, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/Library/Python/2.7/site-packages/django/core/management/base.py", line 317, in run_from_argv
    connections.close_all()
  File "/Library/Python/2.7/site-packages/django/db/utils.py", line 229, in close_all
    for alias in self:
  File "/Library/Python/2.7/site-packages/django/db/utils.py", line 223, in __iter__
    return iter(self.databases)
  File "/Library/Python/2.7/site-packages/django/utils/functional.py", line 35, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "/Library/Python/2.7/site-packages/django/db/utils.py", line 156, in databases
    self._databases = settings.DATABASES
  File "/Library/Python/2.7/site-packages/django/conf/__init__.py", line 53, in __getattr__
    self._setup(name)
  File "/Library/Python/2.7/site-packages/django/conf/__init__.py", line 41, in _setup
    self._wrapped = Settings(settings_module)
  File "/Library/Python/2.7/site-packages/django/conf/__init__.py", line 97, in __init__
    mod = importlib.import_module(self.SETTINGS_MODULE)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/importlib/__init__.py", line 37, in import_module
    __import__(name)
  File "/Users/kaustubhmundra/Desktop/Django/crmeasy/crmapp/settings.py", line 28, in <module>
    ENV_ROLE = get_env_variable('ENV_ROLE')
  File "/Users/kaustubhmundra/Desktop/Django/crmeasy/crmapp/settings.py", line 25, in get_env_variable
    raise ImproperlyConfigured(error_msg)
django.core.exceptions.ImproperlyConfigured: Set the ENV_ROLE environment variable

【问题讨论】:

    标签: python django manage.py


    【解决方案1】:

    正如您的错误消息的最后一行所说:

    Set the ENV_ROLE environment variable
    

    了解此变量的作用 - https://ultimatedjango.com/learn-django/lessons/define-environments/

    但基本上它只是开发阶段(生产/登台/开发)。如果您不关心,请设置为生产。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-06-23
      • 1970-01-01
      • 1970-01-01
      • 2018-09-17
      • 1970-01-01
      • 1970-01-01
      • 2021-05-26
      • 1970-01-01
      相关资源
      最近更新 更多