Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
3.5k views
in Technique[技术] by (71.8m points)

python - dev_appserver.py says Unknown runtime 'python38'

I'm trying to upgrade the GAE runtime on several python projects from python37 to python38. I've used dev_appserver.py to test the apps locally before we deploy but I'm getting an unknown runtime error after changing the runtime to python38. Python 3.8 should be a supported runtime according to the appengine docs.

I've also updated all gcloud cli components to the latest version. Is this just something that's been changed/deprecated and I'm just not aware of it? or is it actually a bug and missing from the dev_appserver.py tool?

Any help would be appreciated! :)

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

Full traceback:

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'.

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

UPDATE: works with python39 runtime as well!


I FOUND A HACKY WORKAROUND!

I found and edited the runtime_factories.py file located in the gcloud devappserver2 tool directory. On my Ubuntu 18.04 install, it was located here:

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

I added python38 to both MODERN_RUNTIMES and FACTORIES like this:

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,
}

Then hit save, and ran dev_appserver.py again and IT WORKED! I've also confirmed that it's actually running python38 runtime!

That means the dev_appserver.py tool's supported runtime list hasn't been updated with the latest python runtimes yet

... Google if you see this please update this tool so others don't have to do this hacky workaround! ??


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...