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

Azure Databricks运行Blob存储Python示例遇导入错误求助

Fixing ImportError: No module named azure.storage.blob in Azure Notebook

Got it, let's get this sorted out for you. The error you're hitting is straightforward—your Azure Notebook environment doesn't have the right version of the Azure Storage SDK installed to match the sample code you're using. Here's exactly what to do:

Step 1: Install the compatible SDK package

Your sample code uses the older v2 Azure Storage SDK API (like BlockBlobService), which lives in the azure-storage package (not the newer azure-storage-blob v12+ package that's installed by default today).

To install the correct version, open a new code cell in your Azure Notebook and run this command:

!pip install azure-storage==2.1.0

The ! prefix tells the Notebook to execute this as a shell command directly. Wait for the installation to finish—you'll see output confirming the package is set up successfully.

Step 2: Run your sample code again

Once the installation completes, go back to your cell with the example.py code and execute it. The from azure.storage.blob import BlockBlobService, PublicAccess line should now work without throwing an import error.

Optional: Auto-install dependencies in your script

If you want to ensure the package is installed every time you run the script (handy for shared notebooks), add this at the very top of your code:

import sys
# Install required package if missing
!{sys.executable} -m pip install azure-storage==2.1.0

Why this works

The newer azure-storage-blob v12+ SDK uses a completely redesigned API (like BlobServiceClient instead of BlockBlobService), which doesn't include the classes your sample code is trying to import. By installing the specific v2 version of azure-storage, you're getting the exact module structure your code expects.

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.11 08:36:53