无法为 Python Azure 函数安装包 [英] Cannot install packages for Python Azure Function

查看:72
本文介绍了无法为 Python Azure 函数安装包的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个在本地执行的 Python Azure 函数.它部署到 Azure,我选择了免费应用计划".Python 依赖于各种模块,例如 requests.这些模块不会像在我的机器上本地那样加载到应用程序中.该函数在触发时失败.

I have a Python Azure function which executes locally. It is deployed to Azure and I selected the 'free app plan'. The Python has dependencies on various modules, such as requests. The modules are not loaded into the app like they are locally on my machine. The function fails when triggered.

  • 我尝试使用我网站上的 Kudu 控制台 安装依赖项,每次都出现正在清理 >> 消息.

  • I have tried installing the dependencies using Kudu console from my site, this hangs with message cleaning up >> every time.

我尝试使用 SSH 终端 从我的站点安装依赖项,安装成功,但当 python pip list 在 kudo 和应用程序仍然失败.我无法浏览目录 ls 什么都不做.

I have tried installing the dependencies using SSH terminal from my site, the installations succeed but i cannot see the modules when python pip list in kudo and the app still fails. I cannot navigate the directories ls does nothing.

我尝试使用门户安装扩展程序,但此选项在开发工具中显示为灰色.

I tried to install extensions using the portal but this option is greyed out in development-tools.

推荐答案

您可以在本地函数文件夹中找到 requirements.txt.

You can find a requirements.txt in your local function folder.

如果你希望azure上的函数安装'requests',你的requirements.txt应该是这样的:(Azure会根据这个文件安装扩展)

If you want function on azure to install the 'requests', your requirements.txt should be like this:(Azure will install the extension based on this file)

azure-functions
requests

并且所有这些包都将在 Azure 上打包成一个新包,因此您无法使用 pip list 显示哪些包.另外,请记住 Linux 的 Kudu 功能是有限的,您无法通过它安装软件包.

And all these packages will be packaged into a new package on Azure, so you can not display which packages using pip list. Also, please keep in mind that Linux's Kudu feature is limited and you cannot install packages through it.

问题似乎来自 VS Code,您可以使用命令来部署您的函数应用.

Problem seems comes from VS Code, you can use command to deploy your function app.

例如,我在 Azure 上的函数应用名为 423PythonBowman2,这是我的命令:

For example, my functionapp on Azure named 423PythonBowman2, So this is my command:

func azure functionapp publish 423PythonBowman --build remote

我在代码中引用了请求,并且使用 cmd deploy 我的函数可以在门户上正常工作,没有错误.

I quoted requests in the code, and with cmd deploy my function can works fine on portal with no errors.

看看官方文档:

https://docs.microsoft.com/en-us/azure/azure-functions/functions-run-local?tabs=macos%2Ccsharp%2Cbash#publish

这篇关于无法为 Python Azure 函数安装包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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