dev_appserver.py说未知的运行时“python38”

我正在尝试将几个 python 项目的 GAE 运行时从 python37 升级到 python38。在我们部署之前,我已经使用 dev_appserver.py 在本地测试应用程序,但是在将运行时更改为 python38 后我收到了一个未知的运行时错误。根据appengine 文档, Python 3.8 应该是受支持的运行时。

我还将所有 gcloud cli 组件更新到最新版本。这只是已被更改/弃用而我只是不知道的东西吗?或者它实际上是一个错误并且从dev_appserver.py工具中丢失了?

任何帮助,将不胜感激!:)

RuntimeError: Unknown runtime 'python38'; supported runtimes are 'custom', 'go', 'go111', 'java', 'java7', 'java8', 'php55', 'php72', 'python', 'python-compat', 
'python27', 'python37'.

完整追溯:

Traceback (most recent call last):
  File "/mnt/c/Users/Admin/AppData/Local/Google/Cloud SDK/google-cloud-sdk/platform/google_appengine/dev_appserver.py", line 96, in <module>
    _run_file(__file__, globals())
  File "/mnt/c/Users/Admin/AppData/Local/Google/Cloud SDK/google-cloud-sdk/platform/google_appengine/dev_appserver.py", line 90, in _run_file
    execfile(_PATHS.script_file(script_name), globals_)
  File "/mnt/c/Users/Admin/AppData/Local/Google/Cloud SDK/google-cloud-sdk/platform/google_appengine/google/appengine/tools/devappserver2/devappserver2.py", line 613, in <module>
    main()
  File "/mnt/c/Users/Admin/AppData/Local/Google/Cloud SDK/google-cloud-sdk/platform/google_appengine/google/appengine/tools/devappserver2/devappserver2.py", line 601, in main
    dev_server.start(options)
  File "/mnt/c/Users/Admin/AppData/Local/Google/Cloud SDK/google-cloud-sdk/platform/google_appengine/google/appengine/tools/devappserver2/devappserver2.py", line 373, in start
    options.api_host, apiserver.port, wsgi_request_info_)
  File "/mnt/c/Users/Admin/AppData/Local/Google/Cloud SDK/google-cloud-sdk/platform/google_appengine/google/appengine/tools/devappserver2/dispatcher.py", line 259, in start
    ssl_port)
  File "/mnt/c/Users/Admin/AppData/Local/Google/Cloud SDK/google-cloud-sdk/platform/google_appengine/google/appengine/tools/devappserver2/dispatcher.py", line 396, in _create_module
    ssl_port=ssl_port)
  File "/mnt/c/Users/Admin/AppData/Local/Google/Cloud SDK/google-cloud-sdk/platform/google_appengine/google/appengine/tools/devappserver2/module.py", line 1313, 
in __init__
    super(AutoScalingModule, self).__init__(**kwargs)
  File "/mnt/c/Users/Admin/AppData/Local/Google/Cloud SDK/google-cloud-sdk/platform/google_appengine/google/appengine/tools/devappserver2/module.py", line 599, in __init__
    self._module_configuration)
  File "/mnt/c/Users/Admin/AppData/Local/Google/Cloud SDK/google-cloud-sdk/platform/google_appengine/google/appengine/tools/devappserver2/module.py", line 226, in _create_instance_factory
    sorted(repr(k) for k in runtime_factories.FACTORIES))))
RuntimeError: Unknown runtime 'python38'; supported runtimes are 'custom', 'go', 'go111', 'java', 'java7', 'java8', 'php55', 'php72', 'python', 'python-compat', 
'python27', 'python37'.

回答

更新:也适用于 python39 运行时!


我找到了一个 hacky 的解决方法!

我找到并编辑了位于 gcloud devappserver2 工具目录中的 runtime_factories.py 文件。在我的 Ubuntu 18.04 安装中,它位于:

/usr/lib/google-cloud-sdk/platform/google_appengine/google/appengine/tools/devappserver2/runtime_factories.py

我添加python38到两者MODERN_RUNTIMESFACTORIES喜欢这样:

MODERN_RUNTIMES = set(['python38', 'python37', 'go111'])


FACTORIES = {
    'go': go_factory.GoRuntimeInstanceFactory,
    'go111': go_factory.GoRuntimeInstanceFactory,
    'php55': php_factory.PHPRuntimeInstanceFactory,
    'php72': php_factory.PHPRuntimeInstanceFactory,
    'python': python_factory.PythonRuntimeInstanceFactory,
    'python38': python_factory.PythonRuntimeInstanceFactory,
    'python37': python_factory.PythonRuntimeInstanceFactory,
    'python27': python_factory.PythonRuntimeInstanceFactory,
    'python-compat': python_factory.PythonRuntimeInstanceFactory,
    'custom': custom_factory.CustomRuntimeInstanceFactory,
}

然后点击保存,再次运行 dev_appserver.py 并且成功了!我还确认它实际上正在运行 python38 运行时!

这意味着 dev_appserver.py 工具支持的运行时列表尚未更新为最新的 python 运行时

...谷歌如果你看到这个请更新这个工具,这样其他人就不必这样做了!

  • Thanks for opening this issue! This is really absolutely stupid. It seems that Google doesn't have enough resources to insert two lines in their scripts to enforce using newer Python runtimes. https://cloud.google.com/appengine/docs/standard/python3/runtime states that Python3.9 support is also already available. I now made your fix and deployed a Python3.9-configured app to app engine, there it works just fine.

以上是dev_appserver.py说未知的运行时“python38”的全部内容。
THE END
分享
二维码
< <上一篇
下一篇>>