python-3.x - 无法在可视代码上使用 anaconda python 3.9 解析 import azure.functions

标签 python-3.x azure visual-studio-code anaconda azure-functions

我正在尝试遵循 Microsoft 上的“Azure Functions with Python”教程:https://learn.microsoft.com/en-us/azure/azure-functions/create-first-function-vs-code-python .

第一行

将 azure.functions 导入为 func

总是被标记为“无法解析(reportMissingImports)” 我在 Visual Code v 1.66.2 上运行它,并在 Windows 10 上使用 python 3.9.7 anaconda 包。我看到了 Unable to import azure.functions in Pycharm 有一个几乎相同的问题(使用 pycharm),但该解决方案对我不起作用。 我确实尝试过 pip install azure-functions,但它(显然)仅适用于较旧的 python 版本。 Anaconda 上的 Microsoft channel 列出了许多 Azure 软件包,但没有列出 azure-functions。 本教程确实没有提到做任何极端的事情。我对 C# azure 函数教程没有任何问题,并希望它是相同的。 我找不到这个包的原因是什么?

谢谢大家

最佳答案

从我们的端复制后,我们可以创建 azure 函数,并在创建虚拟环境后安装所需的 python 模块。以下是创建 python Azure 函数时所需的几个步骤。

  1. 确保已安装 Azure function Core 工具。

  2. 确保您安装了 Python 3.7.x、3.6.x 或 3.8.x 解释器。因此,在通过选择解释器创建时,会创建一个虚拟环境

    enter image description here

  3. 选择一个模板并为其提供名称。

    enter image description here

  4. 选择授权级别并 >> 在新窗口中打开

    enter image description here enter image description here

  5. 创建后,以下是您的应用程序的文件结构

    enter image description here

按照上述步骤后,我们可以创建一个安装了所有必需模块的 Azure 函数。此外,您可以检查requirements.txt 文件以了解已安装哪些模块。

结果:

没有虚拟环境。

enter image description here

使用虚拟环境。

enter image description here

更多信息可以引用How To Create Azure Functions In Python

关于python-3.x - 无法在可视代码上使用 anaconda python 3.9 解析 import azure.functions,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/71877363/

相关文章:

python - 尝试设置小数位数时语法无效

python - 如何从字典中删除南键?

python - 在 Raspbian Buster 上将 Python 3.7 降级到 3.5

azure - 如何在azure虚拟机上打开端口?

css - Visual Studio Code (vscode): Change command palette to look like Atom's one?

typescript - VS Code 提示错误 TS7013 但 Typescript 不是

python-3.x - 在 matplotlib 图形中插入 png 图像

azure - 无法登录 Azure VM

azure - 如何使用 Bicep 创建 Microsoft.DBforPostgreSQL?

visual-studio-code - VS Code 在 Mac 上启动时的空白 UI [os High Sierra]