Python can';t导入已安装的azure.core模块

Python can';t导入已安装的azure.core模块,python,azure,Python,Azure,我正在尝试使用azure get_client_from_cli_配置文件创建ComputeClient,正如我在上看到的那样 导入操作系统 从getpass导入getpass 从azure.mgmt.compute导入ComputeManagementClient 从azure.common.client\u工厂导入从\u cli\u配置文件获取\u客户端\u login=input(“输入您的登录名:”) pwd=getpass(“输入密码:”) 打印(“登录到azure…”) comman

我正在尝试使用azure get_client_from_cli_配置文件创建ComputeClient,正如我在上看到的那样

导入操作系统
从getpass导入getpass
从azure.mgmt.compute导入ComputeManagementClient
从azure.common.client\u工厂导入从\u cli\u配置文件获取\u客户端\u
login=input(“输入您的登录名:”)
pwd=getpass(“输入密码:”)
打印(“登录到azure…”)
command=“az login-u{}-p{}”。格式(login,pwd)
操作系统(命令)
打印(“已登录!”)
打印(“获取资源客户端…”)
资源客户端=从客户端配置文件获取客户端(ComputeManagementClient)
打印(“已获取客户端!”)
但是,在从客户端获取客户端配置文件的过程中,我收到一个错误,表示未安装azure core

Traceback (most recent call last):
  File "test.py", line 14, in <module>
    resource_client = get_client_from_cli_profile(ComputeManagementClient)
  File "/usr/local/lib/python3.6/dist-packages/azure/common/client_factory.py", line 86, in get_client_from_cli_profile
    with_tenant=True,
  File "/usr/local/lib/python3.6/dist-packages/azure/common/credentials.py", line 99, in get_azure_cli_credentials
    cred = _CliCredentials(profile, resource)
  File "/usr/local/lib/python3.6/dist-packages/azure/common/credentials.py", line 50, in __init__
    raise ImportError("You need to install 'azure-core' to use this feature")
ImportError: You need to install 'azure-core' to use this feature
我验证了软件包是否正确安装,以及我是否有权阅读文件夹和文件,所有这些对我来说都很好:

$ pip3 show azure-core
Name: azure-core
Version: 1.2.2
Summary: Microsoft Azure Core Library for Python
Home-page: https://github.com/Azure/azure-sdk-for-python/tree/master/sdk/core/azure-core
Author: Microsoft Corporation
Author-email: azpysdkhelp@microsoft.com
License: MIT License
Location: /home/non/.local/lib/python3.6/site-packages
Requires: six, requests
Required-by:

在启动脚本之前,我尝试了使用az登录,但没有改变结果。

首先,在计算客户端上使用此方法不需要“azure core”,我为此创建了一个问题:

但是,正如您所展示的,您已经安装了“azure core”,所以这很麻烦。你能在问题追踪器上创建一个问题,以便我们进行更深入的对话吗?

编辑:您实际遇到了以下问题:

请不要使用与当前“azure cli核心”不兼容的“azure”元软件包,而是安装“azure mgmt compute”,因此您应该安装此软件包:

azure-mgmt-compute
azure-cli-core
azure-core  # Should not be necessary, bug 10041
如果这不能解决你的问题,请随意提出问题

$ ls -la /usr/local/lib/python3.6/dist-packages/azure/common/
total 48
drwxrwsrwx  3 root staff  4096 févr. 27 10:54 .
drwxrwsrwx 19 root staff  4096 févr. 27 10:54 ..
-rwxrwxrwx  1 root staff 10452 févr. 27 10:54 client_factory.py
-rwxrwxrwx  1 root staff   755 févr. 27 10:54 cloud.py
-rwxrwxrwx  1 root staff  4256 févr. 27 10:54 credentials.py
-rwxrwxrwx  1 root staff   805 févr. 27 10:54 exceptions.py
-rwxrwxrwx  1 root staff  1358 févr. 27 10:54 __init__.py
drwxrwsrwx  2 root staff  4096 févr. 27 10:54 __pycache__
-rwxrwxrwx  1 root staff   328 févr. 27 10:54 _version.py
azure-mgmt-compute
azure-cli-core
azure-core  # Should not be necessary, bug 10041