python3 & google gsutil

Issues related to applications and software problems
Post Reply
B_R_H
Posts: 11
Joined: 2020/09/06 12:06:58

python3 & google gsutil

Post by B_R_H » 2021/08/18 12:35:59

Hi,
I'm running 7.9.2009 on google ce-server, where using gsutil to copy files to storage.
Gsutil will drop support for Python 2.x on October 2021.

There seems to be python3 installed on os, but I do not have any idea, how to make gsutil to use it?

Code: Select all

[root@ce-host ~]# python -V
Python 2.7.5
[root@ce-host ~]# python3 -V
Python 3.6.8
Any recommendations?

User avatar
TrevorH
Site Admin
Posts: 33202
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: python3 & google gsutil

Post by TrevorH » 2021/08/18 13:31:54

What gets invoked as an interpreter depends on the shebang line at the front of the script so amending

#!/usr/bin/python
to
#!/usr/bin/python3

is all that is required to invoke py3 instead of 2.

Please don't be tempted to try redoing the symlink /usr/bin/python to point to python3 or yum and many other system tools will break, badly.

Also, python2 on RHEL/CentOS 7 is supported by Red Hat until EOL in 2024.
The future appears to be RHEL or Debian. I think I'm going Debian.
Info for USB installs on http://wiki.centos.org/HowTos/InstallFromUSBkey
CentOS 5 and 6 are deadest, do not use them.
Use the FAQ Luke

B_R_H
Posts: 11
Joined: 2020/09/06 12:06:58

Re: python3 & google gsutil

Post by B_R_H » 2021/08/22 10:47:26

gsutil is bash-script, but using variable at command line, seem to work

Code: Select all

CLOUDSDK_PYTHON=python3 gsutil version -l

Post Reply