9
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

GCPのCloud Shellのpythonバージョンの更新方法

Posted at

こちらのstack overflowを参考にして書かせていただいています。

How do I install Python 3.7 in google cloud shell

GCPのCloud Shellのpythonが以前からずっと2.7とかで、検索してもあまり結果が出てこなかったので更新方法をまとめておきます。

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

# source で更新する
source ~/.bashrc

これで終わったら一度新たなウィンドウに飛ぶなりしてリセットして、以下のコマンドを打てば更新されていることがわかるはずです。

$ python -V
Python 3.7.4
9
5
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
9
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?