如何在Google Cloud Shell中安装Python 3.7 [英] How do I install Python 3.7 in google cloud shell

查看:251
本文介绍了如何在Google Cloud Shell中安装Python 3.7的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Google云外壳上安装了python 3.5,并希望使用3.7,因此我可以对将要通过Google云功能进行部署的代码进行命令行调试(并使用3.7功能(例如f字符串)).

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 as f-strings).

我尝试以下各种形式:

sudo apt-get install python37

总是回来

Reading package lists... Done
Building dependency tree       
Reading state information... Done
E: Unable to locate package python37

任何帮助将不胜感激!

推荐答案

这在GCP shell上对我有用.

This worked for me on the GCP shell.

# Install requirements
sudo apt-get install -y build-essential checkinstall libreadline-gplv2-dev libncursesw5-dev libssl-dev libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev zlib1g-dev openssl libffi-dev python3-dev python3-setuptools wget 

# Prepare to build
mkdir /tmp/Python37
cd /tmp/Python37

# Pull down Python 3.7, build, and install
wget https://www.python.org/ftp/python/3.7.0/Python-3.7.0.tar.xz
tar xvf Python-3.7.0.tar.xz
cd /tmp/Python37/Python-3.7.0
./configure
sudo make altinstall

然后您将像这样调用Python:

Then you would just call Python like so:

python3.7 ./yourScript.py

Src: 查看全文

登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆