I am trying to install the Google Cloud SDK on my Windows machine. I have Python 2.7 currently installed on this machine, and it's located in the System Variables Path like this -> C:\Python27\;
I am getting this error during installation:
ERROR: gcloud failed to load: DLL load failed: %1 is not a valid Win32 application.
The error message also prompts me to check the Python executable by saying:
If it is not, please set the CLOUDSDK_PYTHON environment variable to point to a working Python 2.7 executable.
So, I'm trying to set the CLOUDSDK_PYTHON environment variable in the install.sh shell script...But nothing is working. Here is the code from that file:
echo Welcome to the Google Cloud SDK!
if [ -z "$CLOUDSDK_PYTHON" ]; then
if [ -z "$(which python)" ]; then
echo
echo "To use the Google Cloud SDK, you must have Python installed and on your PATH."
echo "As an alternative, you may also set the CLOUDSDK_PYTHON environment variable"
echo "to the location of your Python executable."
exit 1
fi
CLOUDSDK_PYTHON="python"
fi
I have tried python2.7
, and the path to the executable, C:\Python27
, but I'm getting this error when I try to run the script with those variables:
install.sh: line 128: $'python\r': command not found
I found this stack question, but none of the solutions worked for me. Any help would be great appreciated.
I had the same issue when the sdk was pointing to the virtualenv python. I solved it by using the default python2.7 in Ubuntu
Type this in termimal
export CLOUDSDK_PYTHON=/usr/bin/python
This is because the gcloud.bat
command can't find the right python.exe. I solved the problem by simply put
SET CLOUDSDK_PYTHON=pathWherePythonexeLocate
into the file cloud_env.bat
in google Cloud SDK file folder.
And revise the install.sh
won't help, because it do nothing to the env
since the install.sh
was run when you first install gcloud sdk.
and sdk only support python2.7, so the path is pointed to python2.7, such as C:\myname\soft\python27.exe
Two configurations fixed my issue with this.
C:\Users\<myusername>\AppData\Local\Microsoft\WindowsApps\python.exe
That file is size 0 Kb. This directory was ahead of the C:\Python27 path where Python was actually installed. I tried moving C:\Python27 higher in the Path string, but this did not work.
While I did not reboot, I did open a fresh CMD window and confirmed that C:\Python27 was higher in the path than the AppData directory. Still did not work.
Making these two changes enabled gCloud to work.
Of course just as I finished typing the above, I saw email from Google regarding the change below.
IMPORTANT NOTE Python 2.7 will no longer get updates after Jan 1, 2020, so gcloud as of v274.0.0 will run with Python 3x. I can't find a web page announcing this, but there is mention of the change on this page: https://cloud.google.com/sdk/docs/quickstart-linux
The way I solved this was simply by downloading the Versioned SDK instead of the Interactive SDK. I manually added gcloud to my path, and all worked. I still don't know why the interactive download was not finding Python from my systems path, but the Versioned SDK without Python worked.
Thanks for the tips @DanCornilescu.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With