【发布时间】:2018-12-28 11:09:54
【问题描述】:
我正在尝试在 Google 计算引擎 Debian VM 实例上部署我的 Django 应用程序,我已经安装了 Python(3.6) 并设置了虚拟环境,然后克隆了在本地系统上运行良好的 Django 应用程序。
当我尝试运行python manage.py migrate 命令时,它返回错误:
ImportError: 没有名为“Fetchors.settings.py”的模块; 'Fetchors.settings' 不是一个包
这是我的Fetchors/wsgi.py:
import os
from django.core.wsgi import get_wsgi_application
from whitenoise.django import DjangoWhiteNoise
path = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
print(path)
if path not in sys.path:
sys.path.append(path)
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "Fetchors.settings")
application = get_wsgi_application()
application = DjangoWhiteNoise(application)
更新:我的目录结构是:
|-Fetchors
|--Fetchors
|--settings.py
|--manage.py
这是我的manage.py:
#!/usr/bin/env python
import os
import sys
if __name__ == "__main__":
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "Fetchors.settings.py")
try:
from django.core.management import execute_from_command_line
except ImportError:
# The above import may fail for some other reason. Ensure that the
# issue is really that Django is missing to avoid masking other
# exceptions on Python 2.
try:
import django
except ImportError:
raise ImportError(
"Couldn't import Django. Are you sure it's installed and "
"available on your PYTHONPATH environment variable? Did you "
"forget to activate a virtual environment?"
)
raise
execute_from_command_line(sys.argv)
这里有什么问题?
提前致谢!
【问题讨论】:
-
您的
Fetchors有settings.py文件吗? -
是的,它有,项目名称是
Fetchors然后主应用程序名称也是Fetchors。所以,我有Fetchors/Fetchors/settings.py -
你在某处添加了
Fetchors.settings.py这一行吗? -
在
wsgi.py中只提到Fetchors.settings
标签: python django debian django-migrations