我试图让Python Google App Engine在本地运行(macOS Sierra)并且遇到各种各样的麻烦,并且想知道我可能会遗漏什么。请注意这是我第一次涉足Python(通常使用Ruby开发)。
我已经为python下载了Google App Engine sdk,并按照步骤启动并运行。经过几次尝试后,我将它放在与我的应用程序相同的目录中。
我使用的是Python 2.7.x,这是应用程序所需要的。
我正在使用virtualenv,所以我已经启动了它:source bin/activate
并尝试像这样运行应用:dev_appserver.py --storage_path=../GAE-storage/ --port=9080 --log_level=info $* .
当我尝试访问该页面时,我收到如下错误:
Traceback (most recent call last):
File "/Users/wm/lib/google-cloud-sdk/platform/google_appengine/google/appengine/runtime/wsgi.py", line 240, in Handle
handler = _config_handle.add_wsgi_middleware(self._LoadHandler())
File "/Users/wm/lib/google-cloud-sdk/platform/google_appengine/google/appengine/api/lib_config.py", line 354, in __getattr__
self._update_configs()
File "/Users/wm/lib/google-cloud-sdk/platform/google_appengine/google/appengine/api/lib_config.py", line 290, in _update_configs
self._registry.initialize()
File "/Users/wm/lib/google-cloud-sdk/platform/google_appengine/google/appengine/api/lib_config.py", line 165, in initialize
import_func(self._modname)
File "/Library/WebServer/Documents/python/flow.city/appengine_config.py", line 19, in <module>
from django.conf import settings
ImportError: No module named django.conf
INFO 2016-11-20 11:09:47,599 module.py:788] default: "GET / HTTP/1.1" 500 -
因此,为了解决这个问题,我手动下载了Django并将其解压缩到app目录。然后它抱怨我没有功能,所以我也手动下载它并添加到项目目录中。现在抱怨其他事情:
ERROR 2016-11-20 11:29:18,635 wsgi.py:263]
Traceback (most recent call last):
File "/Users/wm/lib/google-cloud-sdk/platform/google_appengine/google/appengine/runtime/wsgi.py", line 240, in Handle
handler = _config_handle.add_wsgi_middleware(self._LoadHandler())
File "/Users/wm/lib/google-cloud-sdk/platform/google_appengine/google/appengine/api/lib_config.py", line 354, in __getattr__
self._update_configs()
File "/Users/wm/lib/google-cloud-sdk/platform/google_appengine/google/appengine/api/lib_config.py", line 290, in _update_configs
self._registry.initialize()
File "/Users/wm/lib/google-cloud-sdk/platform/google_appengine/google/appengine/api/lib_config.py", line 165, in initialize
import_func(self._modname)
File "/Library/WebServer/Documents/python/flow.city/appengine_config.py", line 22, in <module>
import features
File "/Library/WebServer/Documents/python/flow.city/flowcity/features.py", line 23, in <module>
from base.basics import get_config
File "/Library/WebServer/Documents/python/flow.city/flowcity/base/basics.py", line 13, in <module>
from dbutils import date_to_str, rescale, get_app_url
File "/Library/WebServer/Documents/python/flow.city/flowcity/dbutils.py", line 23, in <module>
from i18n import _
File "/Library/WebServer/Documents/python/flow.city/flowcity/i18n.py", line 12, in <module>
from django.utils.translation import *
TypeError: Item in ``from list'' not a string
INFO 2016-11-20 11:29:18,641 module.py:788] default: "GET / HTTP/1.1" 500 -
所以我想知道我采用的方法是否是让本地App运行的正确方法?在Ruby中克隆新项目时,我会执行bundle install
,以便下载该项目的所有要求。我应该在Python中使用类似的东西吗?
请注意,我也尝试过没有virtualenv,结果也一样。