How to update the python version of Cloud Shell on GCP

I wrote it with reference to this stack overflow.

How do I install Python 3.7 in google cloud shell

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

How to update the python version of Cloud Shell on GCP
How to get the Python version
How to check the version of Django
How to pass the execution result of a shell command in a list in Python (non-blocking version)
[2020 version] How to install Python3 on AWS EC2
At the time of python update on ubuntu
Work memo to migrate and update Python 2 series scripts on the cloud to 3 series
How to pass the execution result of a shell command in a list in Python
Think about how to program Python on the iPad
How to get the number of digits in Python
How to update Python Tkinter to 8.6
Update python on Mac to 3.7-> 3.8
[Python] Summary of how to specify the color of the figure
How to change Python version
How to enjoy Python on Android !! Programming on the go !!
[Python] Change the Cache-Control of the object uploaded to Cloud Storage
Put the latest version of Python on linux (Debian) on Chromebook
The story of how the Python bottle worked on Sakura Internet
[Hyperledger Iroha] Notes on how to use the Python SDK
Get only the Python version (such as 2.7.5) on the CentOS 7 shell
How to deploy the easiest python textbook pybot on Heroku
[GCP] How to output Cloud Functions log to Cloud Logging (Stackdriver Logging) (Python)
Change the Python version of Homebrew
[Python] How to import the library
Update Python on Mac from 2 to 3
How to change python version of Notebook in Watson Studio (or Cloud Pak for Data)
[OCI] Python script to get the IP address of a compute instance in Cloud Shell
How to know the number of GPUs from python ~ Notes on using multiprocessing with pytorch ~
The story that the version of python 3.7.7 was not adapted to Heroku
How to determine the existence of a selenium element in Python
How to install OpenCV on Cloud9 and run it in Python
How to change the log level of Azure SDK for Python
[GCP] How to publish Cloud Storage signed URLs (temporary URLs) in Python
How to know the internal structure of an object in Python
How to check the memory size of a variable in Python
[Python] How to get the first and last days of the month
After calling the Shell file on Python, convert CSV to Parquet.
How to check the memory size of a dictionary in Python
[Linux] How to disable the automatic update of the /etc/resolv.conf file (AmazonLinux2)
How to use Jupyter on the front end of supercomputer ITO
The first artificial intelligence. How to check the version of Tensorflow installed.
How to set up the development environment of ev3dev [Windows version]
The story of failing to update "calendar.day_abbr" on the admin screen of django
[Python] Summary of how to use pandas
How to read pydoc on python interpreter
[Kivy] How to install Kivy on Windows [Python]
How to update Google Sheets from Python
About the virtual environment of python version 3.7
How to manually update the AMP cache
Clogged with python update of GCP console ①
How to update php on Amazon linux 2
How to erase Python 2.x on Mac.
[Python] Try pydash of the Python version of lodash
Memorandum on how to use gremlin python
[Python2.7] Summary of how to use unittest
How to update security on CentOS Linux 8
How to switch python versions in cloud9
Summary of how to use Python list
[Python2.7] Summary of how to use subprocess
[Question] How to use plot_surface of python
[Python] How to specify the window display position and size of matplotlib