我正在使用ubuntu 16.04设置LexPredict(https://github.com/LexPredict/lexpredict-contraxsuite)和部署设置(https://github.com/LexPredict/lexpredict-contraxsuite-deploy)。
我已经按照部署文档中提到的“本地计算机安装”的所有步骤进行操作,但是出现以下错误:
django.core.exceptions.ImproperlyConfigured: The SECRET_KEY setting must not be empty
执行以下命令后:
./setup_local.sh | tee -a log.txt
我已经从http://www.miniwebtool.com/django-secret-key-generator/在线为django生成了一个密钥,然后以
的形式输入/opt/lexpredict-contraxsuite/contraxsuite_services/settings.py。SECRET_KEY = "yj6o@&vrar6^l1u68!bxugj@xr4&5)zzk!h1qw&13^&@2d3wp#"
以及/opt/lexpredict-contraxsuite-deploy/local/local_settings.py文件中。
但仍然出现相同的错误。 django版本1.11.3
堆栈跟踪:
[localhost] out: Traceback (most recent call last):
[localhost] out: File "/usr/lib/python3.5/runpy.py", line 184, in _run_module_as_main
[localhost] out: "__main__", mod_spec)
[localhost] out: File "/usr/lib/python3.5/runpy.py", line 85, in _run_code
[localhost] out: exec(code, run_globals)
[localhost] out: File "/opt/ve/lib/python3.5/site-packages/celery/__main__.py", line 18, in <module>
[localhost] out: main()
[localhost] out: File "/opt/ve/lib/python3.5/site-packages/celery/__main__.py", line 14, in main
[localhost] out: _main()
[localhost] out: File "/opt/ve/lib/python3.5/site-packages/celery/bin/celery.py", line 326, in main
[localhost] out: cmd.execute_from_commandline(argv)
[localhost] out: File "/opt/ve/lib/python3.5/site-packages/celery/bin/celery.py", line 488, in execute_from_commandline
[localhost] out: super(CeleryCommand, self).execute_from_commandline(argv)))
[localhost] out: File "/opt/ve/lib/python3.5/site-packages/celery/bin/base.py", line 279, in execute_from_commandline
[localhost] out: argv = self.setup_app_from_commandline(argv)
[localhost] out: File "/opt/ve/lib/python3.5/site-packages/celery/bin/base.py", line 481, in setup_app_from_commandline
[localhost] out: self.app = self.find_app(app)
[localhost] out: File "/opt/ve/lib/python3.5/site-packages/celery/bin/base.py", line 503, in find_app
[localhost] out: return find_app(app, symbol_by_name=self.symbol_by_name)
[localhost] out: File "/opt/ve/lib/python3.5/site-packages/celery/app/utils.py", line 374, in find_app
[localhost] out: symbol_by_name=symbol_by_name, imp=imp,
[localhost] out: File "/opt/ve/lib/python3.5/site-packages/celery/app/utils.py", line 358, in find_app
[localhost] out: sym = imp(app)
[localhost] out: File "/opt/ve/lib/python3.5/site-packages/celery/utils/imports.py", line 101, in import_from_cwd
[localhost] out: return imp(module, package=package)
[localhost] out: File "/opt/ve/lib/python3.5/importlib/__init__.py", line 126, in import_module
[localhost] out: return _bootstrap._gcd_import(name[level:], package, level)
[localhost] out: File "<frozen importlib._bootstrap>", line 986, in _gcd_import
[localhost] out: File "<frozen importlib._bootstrap>", line 969, in _find_and_load
[localhost] out: File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked
[localhost] out: File "<frozen importlib._bootstrap>", line 673, in _load_unlocked
[localhost] out: File "<frozen importlib._bootstrap_external>", line 665, in exec_module
[localhost] out: File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
[localhost] out: File "/opt/lexpredict-contraxsuite/contraxsuite_services/apps/celery.py", line 45, in <module>
[localhost] out: django.setup()
[localhost] out: File "/opt/ve/lib/python3.5/site-packages/django/__init__.py", line 22, in setup
[localhost] out: configure_logging(settings.LOGGING_CONFIG, settings.LOGGING)
[localhost] out: File "/opt/ve/lib/python3.5/site-packages/django/conf/__init__.py", line 56, in __getattr__
[localhost] out: self._setup(name)
[localhost] out: File "/opt/ve/lib/python3.5/site-packages/django/conf/__init__.py", line 41, in _setup
[localhost] out: self._wrapped = Settings(settings_module)
[localhost] out: File "/opt/ve/lib/python3.5/site-packages/django/conf/__init__.py", line 129, in __init__
[localhost] out: raise ImproperlyConfigured("The SECRET_KEY setting must not be empty.")
[localhost] out: django.core.exceptions.ImproperlyConfigured: The SECRET_KEY setting must not be empty.
[localhost] out: > celery2@osboxes: * Child terminated with exit code 1
[localhost] out: FAILED
[localhost] out:
答案 0 :(得分:0)
似乎您没有告诉django使用哪个设置。
您可以通过环境变量明确告诉django使用您的设置
DJANGO_SETTINGS_MODULE=<yourmodule>.settings
或作为manage.py的参数:
--settings=<yourmodule>.settings