Python 3.10.10 -没有名为'azure'的模块

fnatzsnv  于 2023-03-31  发布在  Python
关注(0)|答案(1)|浏览(216)

我试图将我的示例应用程序部署到Linux中的Azure应用程序服务。我的应用程序是一个简单的flask应用程序,它从用户那里获取密钥并从Azure密钥库中检索它的值。

from azure.keyvault.secrets import SecretClient
from azure.identity import DefaultAzureCredential

我的requirements.txt如下:

azure-mgmt-resource
Flask==2.0.2
azure-identity==1.10.0
azure-keyvault-secrets==4.6.0

我尝试只添加azure,但它抛出了以下错误,现在我不知道如何退出此循环:

│ exit code: 1
  ╰─> [25 lines of output]
      Traceback (most recent call last):
        File "<string>", line 2, in <module>
        File "<pip-setuptools-caller>", line 34, in <module>
        File "/tmp/pip-install-x2lo6n9j/azure_e4ab6d93138d4411b0a31c7f2ffe6ad2/setup.py", line 60, in <module>
          raise RuntimeError(message)
      RuntimeError:
      
      Starting with v5.0.0, the 'azure' meta-package is deprecated and cannot be installed anymore.
      Please install the service specific packages prefixed by `azure` needed for your application.
      
      The complete list of available packages can be found at:
      https://aka.ms/azsdk/python/all
      
      Here's a non-exhaustive list of common packages:
      
      -  azure-mgmt-compute (https://pypi.python.org/pypi/azure-mgmt-compute) : Management of Virtual Machines, etc.
      -  azure-mgmt-storage (https://pypi.python.org/pypi/azure-mgmt-storage) : Management of storage accounts.
      -  azure-mgmt-resource (https://pypi.python.org/pypi/azure-mgmt-resource) : Generic package about Azure Resource Management (ARM)
      -  azure-keyvault-secrets (https://pypi.python.org/pypi/azure-keyvault-secrets) : Access to secrets in Key Vault
      -  azure-storage-blob (https://pypi.python.org/pypi/azure-storage-blob) : Access to blobs in storage accounts
      
      A more comprehensive discussion of the rationale for this decision can be found in the following issue:
      https://github.com/Azure/azure-sdk-for-python/issues/10646
      
      
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed

× Encountered error while generating package metadata.
╰─> See above for output.

note: This is an issue with the package mentioned above, not pip.
hint: See above for details.
##[error]Bash exited with code '1'.

我在Azure管道中使用的pip安装代码如下:

- script: |
      python -m venv env
      source env/bin/activate
      python -m pip install --upgrade pip
      python -m pip install -r requirements.txt
    displayName: 'Install dependencies'
pgky5nke

pgky5nke1#

***错误原因:***Azure元包无法安装在当前应用程序中。请改为安装应用程序所需的特定提供程序包。

  • 使用以下 * pip * 命令,在 * visual studio code * 终端安装所需的最新版本软件包。*
pip install azure-keyvault-secrets==4.7.0
pip install azure-identity
pip install azure-mgmt-resource
pip install Flask
  • 更新完所有需要的包后,使用下面的 * pip * 命令更新 * requirements.txt * 文件。*
pip install -r requirements.txt

您可以在Azure SDK releases中找到所有Azure SDK。

安装更新成功:

  • 为了检查flask是否运行正常,我创建了一个示例应用程序,它成功运行,如图所示:*

根据您的要求,请参阅key vault secret client library以获取更多相关信息。

相关问题