google-cloud-sdk installation not finding right Python 2.7 version in CentOS /usr/local/bin
Asked Answered
U

4

5

Our server OS is CentOS 6.8, I was trying to install google-cloud-sdk, even though I installed

python 2.7 in /usr/local/bin

, it is still looking at old version of

python 2.6 in /usr/bin

. I tried giving export PATH=/usr/local/bin:$PATH to first look at /usr/local/bin than /usr/bin but still the problem persists. please suggest a way to fix.

Ut answered 28/3, 2017 at 8:39 Comment(1)
I am stuck to same problem and I just found this line in Google cloud SDK docs The Cloud SDK RPM packages are supported for Red Hat Enterprise Level 7 and CentOS 7., so I think CentOS upgrade to version 7 or more is safer option for this problem.Bazooka
G
5

The way I have solved this (and I know it works) is to first install Python 2.7 in whatever way you'd like, then install pip using Python 2.7 which will give you pip2.7. You can then use pip2.7 to install the google_compute_engine module so that it ends up in the right modules folder.

# get pip2.7
wget https://bootstrap.pypa.io/get-pip.py
python2.7 get-pip.py

# install the gcloud module
pip2.7 install google_compute_engine

You can then add this to your $HOME/.bashrc

export CLOUDSDK_PYTHON=/usr/local/bin/python2.7

This is the best repeatable way I know of

Garling answered 8/4, 2017 at 6:48 Comment(0)
S
3

Go to the google-cloud-sdk folder and open the install.sh file. Change the CLOUDSDK_PYTHON="python" value to CLOUDSDK_PYTHON="python2.7"

Rerun the install with the command:

./install.sh

Or you could install it using yum: https://cloud.google.com/sdk/downloads#yum

Squirt answered 28/3, 2017 at 9:40 Comment(1)
there isn't such a CLOUDSDK_PYTHON="python" inside the install.sh file, since a long time ago.Duckworth
S
0

If you are on Windows This is a simple solution that worked for me: open Powershell as administrator and run this to add your Python folder to your environment's PATH: $env:Path += ";C:\python27_x64\"

Then re-run the command that gave you the original error. It should work fine.

Alternatively you could run that original (error-causing) command within the Cloud SDK Shell. That also worked for me.

Salcedo answered 11/1, 2019 at 8:1 Comment(0)
C
0

I found a CLOUDSDK_PYTHON inside my ~/.bash_profile (or ~/.zshenv).

I removed it, and went back into my google-cloud-sdk directory and reinstalled it.

./install.sh

This fixed the issue for me.

Cyme answered 3/6, 2022 at 13:3 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.