python - 如何在 Azure Cloud Shell 中安装 python 3.6

标签 python azure

我正在 python 的帮助下创建一个无服务器函数。但当我尝试启用它时,它说你有 python 3.5。

如何在我们通过 Portal.azure.com 访问的 azure Cloud shell 上安装 python 3.6?

最佳答案

听起来您想在 Azure Cloud Shell 上安装 Python 3.6 而不是 Python 3.5,如下图。

enter image description here

我们首先通过 lsb_release -a 检查 Azure Cloud Shell 中的操作系统版本和uname -a ,如下图。

enter image description here

根据上图结果,我看到是Ubuntu 16.04 x86_64版本。并通过df -a检查文件系统信息,如下图,我也看到它只是一个Ubuntu Docker镜像。

enter image description here

我尝试通过 sudo apt-get install python3.6 进行 Ubuntu 的正常安装操作或apt-get install python3.6 ,但失败,因为没有 sudo命令且当前用户无root权限,如下图。

enter image description here

因此唯一的解决方法是下载预编译的 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 .

这是我的步骤和屏幕截图。

  1. 直接下载安装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 .

    enter image description here

  2. 默认安装路径为~该绝对路径是 /home/<your username> 。只需要配置环境变量 PATH通过命令
    export PATH=~/miniconda3/bin:$PATH
    那么Anaconda的Python 3.6就可以正常工作,如下图。

    enter image description here

即使你切换到PowerShell ,按照下图进行操作也可以使用Anaconda的Python 3.6。

# PowerShell on Azure Cloud Shell
cd ~
cd miniconda3/bin
./python -V

enter image description here

关于python - 如何在 Azure Cloud Shell 中安装 python 3.6,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59640908/

相关文章:

python - 令人困惑的并行 Python 问题 - TRANSPORT_SOCKET_TIMEOUT

python - 将行条目与列名称连接起来

azure - 递归更改访问层

azure - Azure 的 Terraform : storage_os_disk - invalid option

azure - 在Azure表存储中创建目录层次结构

python - 模块未找到错误 : No module named 'Crypto' Error

python - 根据另一列的条件,根据一列的最大值是否等于特定值来过滤组

Python 卡在 lxml.etree.XMLSchema(tree) with apache + mod_wsgi

git - 如何在 Windows Azure 中重置部署凭据?

python - requirements.txt 依赖项未与 Azure Web 应用程序上的代码一起部署