Zeroz
Zeroz

Reputation: 219

Google Cloud SDk: Python was not found

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.

Upvotes: 16

Views: 24014

Answers (3)

johnwargo
johnwargo

Reputation: 787

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

Upvotes: 21

Fabrice Jammes
Fabrice Jammes

Reputation: 3185

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

export CLOUDSDK_PYTHON=/usr/bin/python3

Upvotes: 13

Fariya Rahmat
Fariya Rahmat

Reputation: 3220

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:\Python27\python.exe

4.Run GoogleCloudSDKInstaller.exe again.

Upvotes: 0

Related Questions