Django-App Engine上的gunicorn.错误:'没有名为my_project'的模块;
我正在尝试将Django(v2.0)应用程序上传到Google App Engine,但是Gunicorn(v19.7.1)无法找到我的应用程序.当我使用gcloud app deploy
部署我的应用程序时,出现错误
I'm trying to upload my Django(v2.0) application to Google App Engine, but Gunicorn(v19.7.1) can't find my app. When I deploy my app using gcloud app deploy
I get error
没有名为AppFlex的模块"
'No Module Named AppFlex'
该错误的完整屏幕截图和以下app.yaml配置.
Full screenshot of the error and app.yaml config is below.
wsgi.py 的内容是:
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "AppFlex.settings")
application = get_wsgi_application()
此外,我可以使用以下方式在本地运行该应用程序:
Additionally, I can run the app locally using:
gunicorn AppFlex.wsgi --workers 16
另一个屏幕快照,我可以在其中使用gunicorn在本地运行该应用程序:
Another screenshot where I can run the app using gunicorn locally :
我认为问题在于您的顶级模块(AppFlex
)是驼峰式的,并且出于某些原因,App Engine期望仅使用小写的模块名称.
I think the issue is that your top level module (AppFlex
) is camel-cased, and for some reason App Engine expects only lower case module names.
如果将模块名称更改为appflex
,并在app.yaml
中更新相应的配置,则顶级模块所引用的其他任何地方(例如,在wsgi.pi
中)都应该起作用.
If you change your module name to appflex
and update the corresponding configuration in app.yaml
and everywhere else that your top level module is referenced (e.g., in wsgi.pi
) it should work.
我不太确定为什么App Engine会这样做,但这是模块小写的惯例,我强烈建议您遵循该惯例.
I am not too sure why App Engine is doing that, but it is convention for modules to be lower case, and I'd strongly suggest you follow that convention.