How do I install Python 3.7 in google cloud shell

前端 未结 4 1180
栀梦
栀梦 2020-12-08 01:27

I have python 3.5 on my google cloud shell and want 3.7 so I can do command line debugging of code I am going to deploy via google cloud functions (and use 3.7 features such

4条回答
  •  [愿得一人]
    2020-12-08 02:07

    Even if the packages were available through apt, the downside of using apt would be that you'd have to install all over again whenever you'd been disconnected from Cloud Shell: it always discards your runtime container.

    I'd recommend using https://github.com/pyenv/pyenv for convenience. If you follow the installation guide (and note the bash profile additions should go into .bashrc in our case) you end up with a python build in your home directory, which is persisted across Cloud Shell sessions. This involves just a few steps:

    1. clone the repo into ~/.pyenv
    2. append three lines (see the README) to .bashrc to adjust your $PATH
    3. pyenv install 3.7.3 # this takes a while to build
    4. pyenv global 3.7.3 # sets this version as the default

提交回复
热议问题