我正在尝试在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)
这有什么问题吗?
谢谢!
答案 0 :(得分:0)
在最里面的Fetchors文件夹中添加const arr = [9,5,'2','ab','3',-1];
const nums = arr.filter(n => typeof n == "number").sort(); // If the data type of a given element is a number store it in this array (and then sort)
const non_nums = arr.filter(x => typeof x != "number").sort(); // Store everything that is not a number in an array (and then sort)
const res = [...nums, ...non_nums]; // combine the two arrays
console.log(res); // [-1, 5, 9, "2", "3", "ab"]
文件(如果不可用)。
因此您的目录结构应如下所示:
__init__.py
这使python知道对待Fetchors是一个包。 |-Fetchors
|--Fetchors
|--__init__.py
|--settings.py
|--manage.py
可以为空文件。它应该已经存在于文件夹中。