dev_appserver.py 启动失败

dev_appserver.py fails on startup

使用 dev_appserver.py 启动本地开发服务器时出现以下错误。

$ dev_appserver.py app.yaml
INFO     2017-07-03 06:51:09,662 devappserver2.py:116] Skipping SDK update check.
Traceback (most recent call last):
  File "/home/daniel/google-cloud-sdk/platform/google_appengine/dev_appserver.py", line 103, in <module>
    _run_file(__file__, globals())
  File "/home/daniel/google-cloud-sdk/platform/google_appengine/dev_appserver.py", line 97, in _run_file
    execfile(_PATHS.script_file(script_name), globals_)
  File "/home/daniel/google-cloud-sdk/platform/google_appengine/google/appengine/tools/devappserver2/devappserver2.py", line 381, in <module>
    main()
  File "/home/daniel/google-cloud-sdk/platform/google_appengine/google/appengine/tools/devappserver2/devappserver2.py", line 369, in main
    dev_server.start(options)
  File "/home/daniel/google-cloud-sdk/platform/google_appengine/google/appengine/tools/devappserver2/devappserver2.py", line 176, in start
    configuration.modules[0].application_root, datastore_emulator_host)
  File "/home/daniel/google-cloud-sdk/platform/google_appengine/google/appengine/tools/devappserver2/api_server.py", line 524, in create_api_server
    appidentity_oauth_url=options.appidentity_oauth_url)
  File "/home/daniel/google-cloud-sdk/platform/google_appengine/google/appengine/tools/devappserver2/api_server.py", line 699, in setup_stubs
    oauth_url=appidentity_oauth_url)
  File "/home/daniel/google-cloud-sdk/platform/google_appengine/google/appengine/api/app_identity/app_identity_stub.py", line 198, in Create
    import six
  File "/home/daniel/google-cloud-sdk/platform/google_appengine/lib/six-1.9.0/six/__init__.py", line 825, in <module>
    from . import test_six
  File "/home/daniel/google-cloud-sdk/platform/google_appengine/lib/six-1.9.0/six/test_six.py", line 105, in <module>
    @py.test.mark.parametrize("item_name",
AttributeError: 'NoneType' object has no attribute 'parametrize'

版本:

$ gcloud --version
Google Cloud SDK 161.0.0
app-engine-python 1.9.55
beta 2017.03.24
bq 2.0.24
core 2017.06.26
gcloud 
gsutil 4.26

gcloud-sdk 组件 app-engine-python==1.9.55 销售的 six==1.9.0 库似乎依赖于 pytest

问题已通过安装 pytest

解决
$ pip install pytest

查看问题:https://issuetracker.google.com/issues/62980070

只有在本地安装了 pytest 版本 < 2.2.0 的用户才会出现此问题,当前版本为 3.1.3。如果 (a) 他们没有安装 pytest 或 (b) 安装了 pytest >= 2.2.0,用户将不会看到此问题。堆栈跟踪末尾的 @py.test.mark.parametrize() 装饰器是在 2.2.0.

中引入的

我们已经为 pytest < 2.2.0 的用户提交了解决此问题的补丁,该补丁将在下一个 App Engine SDK 版本中提供。同时,用户可以在本地升级他们的 pytest 版本,问题应该会消失。