我正在 python 的帮助下创建一个无服务器函数。但当我尝试启用它时,它说你有 python 3.5。
如何在我们通过 Portal.azure.com 访问的 azure Cloud shell 上安装 python 3.6?
最佳答案
听起来您想在 Azure Cloud Shell 上安装 Python 3.6 而不是 Python 3.5,如下图。
我们首先通过 lsb_release -a
检查 Azure Cloud Shell 中的操作系统版本和uname -a
,如下图。
根据上图结果,我看到是Ubuntu 16.04 x86_64版本。并通过df -a
检查文件系统信息,如下图,我也看到它只是一个Ubuntu Docker镜像。
我尝试通过 sudo apt-get install python3.6
进行 Ubuntu 的正常安装操作或apt-get install python3.6
,但失败,因为没有 sudo
命令且当前用户无root权限,如下图。
因此唯一的解决方法是下载预编译的 Python 3.6 版本并安装。 Python官方网站只发布了tar.gz
的源代码存档文件。后缀,不是 Linux 的预编译版本,太复杂,需要花费很长时间编译 Python 源代码才能通过 gcc
获得 Python 运行时及其库依赖项,所以最后我决定安装 miniconda
Python 3.6 的发布,来自https://repo.continuum.io/miniconda/ ,我用的是https://repo.continuum.io/miniconda/Miniconda3-4.5.4-Linux-x86_64.sh .
这是我的步骤和屏幕截图。
直接下载安装shell文件
Miniconda3-4.5.4-Linux-x86_64.sh
并通过命令安装
wget https://repo.continuum.io/miniconda/Miniconda3-4.5.4-Linux-x86_64.sh
和
sh Miniconda3-4.5.4-Linux-x86_64.sh
.默认安装路径为
~
该绝对路径是/home/<your username>
。只需要配置环境变量PATH
通过命令
export PATH=~/miniconda3/bin:$PATH
那么Anaconda的Python 3.6就可以正常工作,如下图。
即使你切换到PowerShell
,按照下图进行操作也可以使用Anaconda的Python 3.6。
# PowerShell on Azure Cloud Shell
cd ~
cd miniconda3/bin
./python -V
关于python - 如何在 Azure Cloud Shell 中安装 python 3.6,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59640908/