我正在尝试将几个python项目的GAE运行时从python37升级到python38。在部署之前,我已经使用dev_appserver.py在本地测试了应用程序,但在将运行时更改为python38后,我遇到了未知的运行时错误。根据appengine文档,Python 3.8应该是一个受支持的运行时。
我还将所有gcloudcli组件更新到了最新版本。这只是被更改/弃用的东西吗?我只是不知道吗?还是它实际上是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'.
UPDATE:也适用于python39运行时!
我发现了一个棘手的问题!
我在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_RUNTIMES
和FACTORIES
中,如下所示:
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,
}
然后点击save,再次运行dev_appserver.py,一切正常!我还确认了它实际上在运行python38运行时!
这意味着dev_appserver.py工具支持的运行时列表还没有更新为最新的python运行时
谷歌,如果你看到这个,请更新这个工具,这样其他人就不必做这个棘手的解决方案!🙏