Google Cloud SDk: Python was not found

Question:

After I install Google cloud sdk in my computer, I open the terminal and type "gcloud –version" but it says "python was not found"

note:
I unchecked the box saying "Install python bundle" when I install Google cloud sdk because I already have python 3.10.2 installed.

so, how do fix this?

Thanks in advance.

Asked By: Zeroz

||

Answers:

As mentioned in the document:

Cloud SDK requires Python; supported versions are Python 3 (preferred,
3.5 to 3.8) and Python 2 (2.7.9 or later). By default, the Windows version of Cloud SDK comes bundled with Python 3 and Python 2. To use
Cloud SDK, your operating system must be able to run a supported
version of Python.

As suggested by @John Hanley the CLI cannot find Python which is already installed. Try reinstalling the CLI selecting install Python bundle. If you are still facing the issue another workaround can be to try with Python version 2.x.x .

You can follow the below steps :

1.Uninstall all Python version 3 and above.

2.Install Python version -2.x.x (I have installed – 2.7.17)

3.Create environment variable – CLOUDSDK_PYTHON and provide value as C:Python27python.exe

4.Run GoogleCloudSDKInstaller.exe again.

Answered By: Fariya Rahmat

On ubuntu Linux, you can define this variable in the .bashrc file:

export CLOUDSDK_PYTHON=/usr/bin/python3
Answered By: Fabrice Jammes

On Windows, setting the CLOUDSDK_PYTHON environment variable fixes this, but when I first tried this I pointed the variable to the folder containing the python executable and that didn’t work. The variable apparently must point to the executable file. enter image description here

Answered By: johnwargo
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.