Search code examples
pythonazuredatabricksazure-databricksfileshare

Databricks: No module named azure.storage


I was following the answer in this question Load file from Azure Files to Azure Databricks to create the SAS token with the following code

# Create a client of Azure File Service as same as yours
from azure.storage.file import FileService

account_name = '<your account name>'
account_key = '<your account key>'
share_name = 'test'
directory_name = None
file_name = 'test.xlsx'

file_service = FileService(account_name=account_name, account_key=account_key)

But I got the error:

ModuleNotFoundError: No module named 'azure.storage'

I already install the module with these commands

!pip install azure
!pip install azure-storage
!pip install azure-storage-file

And I installed the same modules into the cluster as you can see in the caption enter image description here

None of the previous attempts was able to fix my "ModuleNotFoundError: No module named 'azure.storage'"

enter image description here Does anyone have a way to fix this issue?


Solution

  • This class is located in another package: azure.storage.file.fileservice (doc), so you need to write:

    from azure.storage.file.fileservice import FileService