You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何查询Azure Notebook的Python SDK版本及解决Blob导入错误

Troubleshooting BlobServiceClient Import Error in Azure Notebooks

Hey there! Let's work through your Azure Storage Blob SDK issues step by step.

How to Check Your Azure Storage SDK Version

To confirm exactly which versions of the Azure Storage libraries are running in your Azure Notebook environment, run these commands directly in a notebook cell:

  • Check the legacy azure-storage package version:

    !pip show azure-storage
    

    Or verify within Python:

    import azure.storage
    print(azure.storage.__version__)
    
  • Check the modern azure-storage-blob package version:

    !pip show azure-storage-blob
    

    Or verify within Python:

    import azure.storage.blob
    print(azure.storage.blob.__version__)
    

Your hunch about version differences is totally right: the BlobServiceClient class belongs to Azure Storage Blob SDK v12+, while older versions (like v0.36.0 of azure-storage) rely on BlockBlobService instead.

Fixing the ImportError: cannot import name 'BlobServiceClient'

The core problem here is a namespace conflict between the legacy azure-storage package (v0.36.0) and the modern azure-storage-blob package (v12.3.0) you installed. These two packages overlap in their module structure, causing import confusion. Here's how to resolve it:

  1. Uninstall conflicting packages to clean up your environment:

    !pip uninstall -y azure-storage azure-storage-blob
    
  2. Reinstall only the modern, standalone SDK:

    !pip install azure-storage-blob --upgrade
    
  3. Verify the installation to confirm you're on v12+:

    import azure.storage.blob
    print(azure.storage.blob.__version__)
    
  4. Use the correct import statement for v12+ SDK:

    from azure.storage.blob import BlobServiceClient
    

Why didn't upgrading azureml-sdk help? The azureml-sdk often includes a dependency on the legacy azure-storage package, which would reintroduce the conflict. By explicitly uninstalling and reinstalling the standalone azure-storage-blob package, you ensure you're using the modern library structure.

If you need to work with the legacy SDK for compatibility reasons, use this import instead:

from azure.storage.blob import BlockBlobService

内容的提问来源于stack exchange,提问作者SeaDude

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.07 10:37:33