azureazure-blob-storagefsspec

Using AzureBlobFileSystem to Access Azure Blob Storage Fails with Import Error


I'm trying to use AzureBlobFileSystem from the adlfs library to access Azure Blob Storage as a file system in Python. I’m encountering an import error and would appreciate any help.

I’ve installed azure-storage-blob and adlfs:

pip install azure-storage-blob adlfs

My code:

import fsspec
from adlfs import AzureBlobFileSystem
abfs = AzureBlobFileSystem(account_name=account_name,account_key="")

When I run this code, I get the following error: from adlfs import AzureBlobFileSystem ImportError: cannot import name 'AzureBlobFileSystem' from partially initialized module 'adlfs' (most likely due to a circular import)

What I've Tried:

  1. Verified that my account name and key are correct.
  2. Ensured that azure-storage-blob and adlfs are both installed and up-to-date.
  3. Checked my network connection and confirmed I have access to the storage account.

Environment detail : Editor - VS code on Mac os python - 3.13.0 adlfs - 2024.7.0
azure-storage-blob - 12.23.1

I am using all the latest version for azure libraries. Has anyone encountered this before or have any suggestions on how to resolve it? Thank you for your help!


Solution

  • The issue was due to naming my Python file with an existing Python keyword (e.g., azure.py).

    Solution: I renamed the file to something unique, avoiding reserved keywords and built-in module names. For example, instead of class.py, I renamed it to my_class.py, which resolved the error.

    Thanks to everyone who tried to look into this !!