Microsoft Azure的Python库

时间:2019-03-11 08:18:10

标签: python azure

我正在使用python代码导入azure活动日志,但是下面给出的模块错误是错误

 from azure.monitor import MonitorClient

文件“ /home/seceon/azure.py”,第1行,在     从azure.monitor导入MonitorClient ImportError:没有名为Monitor的模块

我需要帮助来删除此导入错误。

2 个答案:

答案 0 :(得分:2)

好像您已将脚本命名为azure.py 这与已安装的azure-monitor模块冲突。我建议您将脚本重命名为其他名称,然后尝试再次运行它。 它应该开始工作。

答案 1 :(得分:1)

这是一个软件包azure-monitor,您在较早版本的适用于Python的Azure SDK中用于Azure服务管理,其GitHub repo标签为azure-monitor_0.3.1。您可以在https://pypi.org/project/azure-monitor/上看到它。

要安装它,我在当前的Python 3.6.7中创建了一个虚拟环境。这是我的步骤。

  1. 命令virtualenv azure-monitor-testcd azure-monitor-test
  2. 命令source bin/activate
  3. 命令pip install azure-monitor
  4. 在我的Python解释器中成功运行from azure.monitor import MonitorClient,如下图。

enter image description here

  1. 通过命令pip list | grep azure检查我已安装的pip软件包,然后您将看到其相关软件包的这些版本,如下所示。

enter image description here