简体   繁体   中英

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

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.

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

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

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM