I have the gsutil Tool installed on a CentOS 6.5 box which requires Python 2.6. According to CentOS 6.5 docs, we can't upgrade this to Python 2.7, but we can install and use Python 2.7 as a separate install to 2.6 as long as 2.6 remains as the system default. I have installed Python 2.7 already as its own stand-alone instance and it is working fine.
According to Google, gsutils will not support Python 2.6 after 9/1/2016:
Warning: You are running Python 2.6, which stopped receiving security patches as of October 2013. gsutil will stop supporting Python 2.6 on September 1, 2016. Please update your Python installation to 2.7 to ensure compatibility with future gsutil versions.
I'm looking for a way to point gsutils to the directory where Python 2.7 is installed without changing the env variables or anything that affects the default 2.6 installation. Any help would be greatly appreciated.
Copy a file from a bucket to your local computer with gsutil : gsutil cp gs://my-gsutil-bucket-12005/test-renamed.txt . Copy a file from a bucket to your local computer with Python: Note that unlike with gsutil , with Python, you must specify a valid path for the local file name to store the remote object.
gsutil is a Python application that lets you access Cloud Storage from the command line. You can use gsutil to do a wide range of bucket and object management tasks, including: Creating and deleting buckets. Uploading, downloading, and deleting objects.
Building on Brian's answer (and I suspect everyone's hitting this because of the 9/1/16 message!) , you could also add the same thing,
export CLOUDSDK_PYTHON=python2.7
to /etc/environment (on most Linux distros) to have it impact all users.
gsutil will use the first python
executable on your path.
The general approach you can use is to make a new directory with python symlinked to the binary you want to use and then add that to your path.
For example:
$ mkdir ~/python27-bin
$ ln -s /usr/bin/python2.7 ~/python27-bin/python
$ PATH=~/python27-bin:$PATH ./gsutil version -l | grep python
python version: 2.7.6
To make it easier, you could create a wrapper script called gsutil-2.7
that amends the path for you.
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