如何解决尝试使用Python库Azure-storage-blob时无法解析的导入'azure.storage.blob'
我正在尝试使用Python库azure-storage-blob提取存储在blob中的文件的文件名。我已经使用conda安装了所有必需的软件包,如下所述,因为我在anaconda中使用虚拟环境。
conda install -c anaconda azure conda安装-c conda-forge azure-storage-blob conda安装-c conda-forge azure-nspkg
但是我的代码无法编译并显示错误消息Unresolved import'azure.storage.blob' 我也有一个错误: ModuleNotFoundError:没有名为“ azure”的模块
但是,我已经安装了这些软件包。您能告诉我如何解决此问题吗?
这是我的代码:
import os,uuid
from azure.storage.blob import BlobClient,BlobServiceClient,ContainerClient,__version__
try:
print("Azure Blob Storage v" + __version__ + " - Python sample")
except Exception as ex:
print('Exception:')
print(ex)
# Retrieve the connection string for use with the application. The storage
# connection string is stored in an environment variable on the machine
# running the application called AZURE_STORAGE_CONNECTION_STRING. If the environment variable is
# created after the application is launched in a console or with Visual Studio,# the shell or application needs to be closed and reloaded to take the
# environment variable into account.
connect_str = os.getenv('AZURE_STORAGE_CONNECTION_STRING')
# Create BlobServiceClient object
blob_service_client = BlobServiceClient.from_connection_string(connect_str)
containers_list = blob_service_client.list_containers
print(containers_list)
解决方法
我发现使用Visual Studio代码,这并不是真正的错误。当我尝试使用命令python
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。