CloudShell seems to be using Python version 2.7 as a default command line interpreter. This might be due to some Cloud SDK tools that are still reliant on version 2.7 as explained in this
document:
"Other Python tools shipped in the Cloud SDK do not support Python 3 and require Python 2.7.x, including: dev_appserver endpointscfg".
Though looking at the Cloud SDK ( version 348.0.0) configs in cloudshell , it seems that it is already using version 3 :
gcloud info | grep Python
Python Version: [3.7.3 (default, Jan 22 2021, 20:04:44) [GCC 8.3.0]]
Python Location: [/usr/bin/python3]
Python PATH: [/usr/bin/../lib/google-cloud-sdk/lib/third_party:/usr/lib/google-cloud-sdk/lib:/usr/lib/python37.zip:/usr/lib/python3.7:/usr/lib/python3.7/lib-dynload]
Answering your question and as CloudShell (which is based on Debian Linux ) already includes Python version 3, you can point the
symlink to it. I found this
third party article that can help. As per the same article you can also switch between versions if needed.
Example of configuring Python 3 as a priority "1" (notice trailing 1 at the end of "update-alternative" command below) :
$ ls /usr/bin/python*
/usr/bin/python /usr/bin/python2 /usr/bin/python2.7 /usr/bin/python2.7-config /usr/bin/python3 /usr/bin/python3.7 /usr/bin/python3.7-config /usr/bin/python3.7m /usr/bin/python3.7m-config /usr/bin/python3m
$ sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.7 1
update-alternatives: using /usr/bin/python3.7 to provide /usr/bin/python (python) in auto mode
$ python --version
********************************************************************************
Python 2 is deprecated. Upgrade to Python 3 as soon as possible.
See https://cloud.google.com/python/docs/python2-sunset
To suppress this warning, create an empty ~/.cloudshell/no-python-warning file.
The command will automatically proceed in seconds or on any key.
********************************************************************************
Python 3.7.3
If you need further help with the current config, I suggest posting on
Stack Exchange as you have a larger community of Linux experts that can assist with Linux workarounds. I hope the above is helpful.