I wrote it with reference to this stack overflow.
GCP's Cloud Shell python has been 2.7 for a long time, and I did not get much results even if I searched, so I will summarize the update method.
Use pyenv.
#install pyenv to install python on persistent home directory
curl https://pyenv.run | bash
# add to path
echo 'export PATH="$HOME/.pyenv/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(pyenv init -)"' >> ~/.bashrc
echo 'eval "$(pyenv virtualenv-init -)"' >> ~/.bashrc
# install python 3.7.4 and make default
pyenv install 3.7.4
pyenv global 3.7.4
#Update with source
source ~/.bashrc
Once this is done, you should jump to a new window, reset it, and type the following command to see that it has been updated.
$ python -V
Python 3.7.4
Recommended Posts