I have a little confused about gcloud with python3
After I installed gcloud in python3 env and I tried to example Quickstart for Python in the App Engine Flexible Environment.
It said 'You need Google Cloud SDK', so I installed SDK. All the process after SDK(including SDK), It needs python2 env.
Here is a question, Is is impossible to run gcloud with python3 (officially ) yet? (SDK and python2 with gcloud library is best way?)
gcloud-python and gcloud-cli as in Cloud SDK are somewhat unrelated products. It is true that you need python 2.7.x to run gcloud-cli, but that does no preclude you from using python3 with gcloud-python library.
If you install multiple versions of python 2.7x and 3.5 for example (you can even make python3 default) as long as you set CLOUDSDK_PYTHON environment variable to point to python 2.7.x interpreter you should be able to run gcloud-cli while using python3 for your project.
On Windows for example, Cloud SDK packages its own python which does not conflict with any other version you might have on your system. It is pure runtime dependency for gcloud-cli.
I worked around this issue by specifying the path to Python 2 (that I named
python2
on my system).I suggest adding the export to your
.bashrc
or.zshrc
file.As of 2019-12-17, version 274.0.0 officially supports Python 3. Release notes:
(That command shows that
dev_appserver
andendpointscfg
are the exceptions.)According to the search order, gcloud will still use Python 2 if it finds it. You can be explicit by setting
CLOUDSDK_PYTHON=python3
(or similar) as an environment variable.Inside the
install.sh
, it says python3 is supported but not prioritised because python 2 is, I think, more ubiquitous. It means if you are running macOS, add a line of environment variable byecho "export CLOUDSDK_PYTHON=/your/path/to/python3" >> ~/.bash_profile
will allow gcloud to use whichever python3 is located.If it doesn't work, then point it to whichever python 2 and only use python 3 for your own work should solve the problem.
The system requirement explicitly said python 2.7.x https://cloud.google.com/sdk/downloads
why do you want to run gcloud with python3 anyway?