从django 1.9.6升级到1.11.11后,由于未找到DJANGO_SETTINGS_MODULE(“simpl_calc_model.settings”),运行带有以下guest虚拟机工作程序配置的crossbar 17.10.1失败。
{
"type": "guest",
"executable": "django-admin",
"arguments": ["run_guest"],
"options": {
"workdir": "..",
"env": {
"vars": {
"HOSTNAME": "localhost",
"PORT": "8080"
}
}
}
}
我正在使用包含simpl_calc_model目录的项目中的管理命令对此配置运行crossbar。我可以直接在这个项目中运行guest worker:
./manage.py run_guest --settings=simpl_calc_model.settings
如何确保django-admin 1.11.11可以通过我的管理命令从crossbar调用时找到设置模块?
错误日志如下所示:
Traceback (most recent call last):
File " ~/.virtualenvs/simpl-calc-model/bin/django-admin", line 11, in <module>
sys.exit(execute_from_command_line())
File " ~/.virtualenvs/simpl-calc-model/lib/python3.6/site-packages/django/core/management/__init__.py", line 364, in execute_from_command_line
utility.execute()
File " ~/.virtualenvs/simpl-calc-model/lib/python3.6/site-packages/django/core/management/__init__.py", line 308, in execute
settings.INSTALLED_APPS
File " ~/.virtualenvs/simpl-calc-model/lib/python3.6/site-packages/django/conf/__init__.py", line 56, in __getattr__
self._setup(name)
File " ~/.virtualenvs/simpl-calc-model/lib/python3.6/site-packages/django/conf/__init__.py", line 41, in _setup
self._wrapped = Settings(settings_module)
File " ~/.virtualenvs/simpl-calc-model/lib/python3.6/site-packages/django/conf/__init__.py", line 110, in __init__
mod = importlib.import_module(self.SETTINGS_MODULE)
File " ~/.virtualenvs/simpl-calc-model/lib/python3.6/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 994, in _gcd_import
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 941, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "<frozen importlib._bootstrap>", line 994, in _gcd_import
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 953, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'simpl_calc_model'
答案 0 :(得分:0)
通过实施Alasdair的建议并删除workdir修复了问题:
{
"type": "guest",
"executable": "manage.py",
"arguments": ["run_guest"],
"options": {
"env": {
"vars": {
"HOSTNAME": "localhost",
"PORT": "8080"
}
}
}
}