如何解决AzureClicredential的问题?
以下是我的代码,在Linux中,我已通过AZ登录登录到Azure,但是当我尝试运行以下代码时,它会给我一个错误
(最新调用最后): 文件“ scan.py”,第1行,in 从azure.Identimity导入AzureCrecredential
I还安装了PIP安装Azure-Identity,但仍然相同。
#CODE#
from azure.identity import AzureCliCredential
from azure.mgmt.subscription import SubscriptionClient
import json
credential = AzureCliCredential()
subscription_client = SubscriptionClient(credential)
sub_list = subscription_client.subscriptions.list()
for sub in list(sub_list):
subs_id = sub.subscription_id
print(subs_id)
The following is my code and in linux I have logged in to azure via az login but when I try to run the below code it gives me an error that
Traceback (most recent call last):
File "scan.py", line 1, in
from azure.identity import AzureCliCredential
I also installed the pip install azure-identity but its still the same.
#CODE#
from azure.identity import AzureCliCredential
from azure.mgmt.subscription import SubscriptionClient
import json
credential = AzureCliCredential()
subscription_client = SubscriptionClient(credential)
sub_list = subscription_client.subscriptions.list()
for sub in list(sub_list):
subs_id = sub.subscription_id
print(subs_id)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Glad @ Ghostrider 您自己解决了问题。
如您没有提及哪种版本的Python,您正在使用,但是现在通过使用Python 3来解决。
我还在使用Python 3.9版本的本地VS代码中运行此代码,并获得了成功的结果:
,也观察到代码中存在的软件包
Azure-Indentity
由Python版本3.6或最新版本支持,如 Python包装库官方网站。Glad @Ghostrider that you had resolved the issue yourself.
As you did not mention what version of python, you're using earlier, but for now resolved by using python 3.
I also run this code in my local VS Code with the Python 3.9 Version and got the successful result:
Also, observed the packages present in the code that the package
azure-identity
is supported from Python Version 3.6 or the latest versions, as given in the Python Packages Library Official Site.