使用 python manage.py runserver 正常启动,使用 django-admin 出错。查看 manage.py 中也是用的'Bill.settings',参考了 overflow 加了命令的参数还是不行,请教大家到底啥原因,如何解决
使用命令
django-admin runserver 8054 --settings="Bill.settings" --pythonpath=.
出现错误
(venv-django2.2) D:\PythonApp\Bill>django-admin runserver 8054 --settings="Bill.settings" --pythonpath="D:\Program Files\Python\Python36"
Traceback (most recent call last):
File "d:\pythonapp\venvs\venv-django2.2\lib\site-packages\django\core\management\base.py", line 323, in run_from_argv
self.execute(*args, **cmd_options)
File "d:\pythonapp\venvs\venv-django2.2\lib\site-packages\django\core\management\commands\runserver.py", line 60, in execute
super().execute(*args, **options)
File "d:\pythonapp\venvs\venv-django2.2\lib\site-packages\django\core\management\base.py", line 364, in execute
output = self.handle(*args, **options)
File "d:\pythonapp\venvs\venv-django2.2\lib\site-packages\django\core\management\commands\runserver.py", line 67, in handle
if not settings.DEBUG and not settings.ALLOWED_HOSTS:
File "d:\pythonapp\venvs\venv-django2.2\lib\site-packages\django\conf\__init__.py", line 79, in __getattr__
self._setup(name)
File "d:\pythonapp\venvs\venv-django2.2\lib\site-packages\django\conf\__init__.py", line 66, in _setup
self._wrapped = Settings(settings_module)
File "d:\pythonapp\venvs\venv-django2.2\lib\site-packages\django\conf\__init__.py", line 157, in __init__
mod = importlib.import_module(self.SETTINGS_MODULE)
File "D:\Program Files\Python\Python36\lib\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 'Bill'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "D:\Program Files\Python\Python36\lib\runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "D:\Program Files\Python\Python36\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "D:\PythonApp\venvs\venv-django2.2\Scripts\django-admin.exe\__main__.py", line 9, in <module>
File "d:\pythonapp\venvs\venv-django2.2\lib\site-packages\django\core\management\__init__.py", line 381, in execute_from_command_line
utility.execute()
File "d:\pythonapp\venvs\venv-django2.2\lib\site-packages\django\core\management\__init__.py", line 375, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "d:\pythonapp\venvs\venv-django2.2\lib\site-packages\django\core\management\base.py", line 336, in run_from_argv
connections.close_all()
File "d:\pythonapp\venvs\venv-django2.2\lib\site-packages\django\db\utils.py", line 219, in close_all
for alias in self:
File "d:\pythonapp\venvs\venv-django2.2\lib\site-packages\django\db\utils.py", line 213, in __iter__
return iter(self.databases)
File "d:\pythonapp\venvs\venv-django2.2\lib\site-packages\django\utils\functional.py", line 80, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "d:\pythonapp\venvs\venv-django2.2\lib\site-packages\django\db\utils.py", line 147, in databases
self._databases = settings.DATABASES
File "d:\pythonapp\venvs\venv-django2.2\lib\site-packages\django\conf\__init__.py", line 79, in __getattr__
self._setup(name)
File "d:\pythonapp\venvs\venv-django2.2\lib\site-packages\django\conf\__init__.py", line 66, in _setup
self._wrapped = Settings(settings_module)
File "d:\pythonapp\venvs\venv-django2.2\lib\site-packages\django\conf\__init__.py", line 157, in __init__
mod = importlib.import_module(self.SETTINGS_MODULE)
File "D:\Program Files\Python\Python36\lib\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 'Bill'
这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。
V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。
V2EX is a community of developers, designers and creative people.