0

I am trying to perform the import of the azure.storage.blob module into a python script defined within the "Run Python Script" activity of Power Automate Desktop.

# Python 2.7 code
from azure.storage.blob import BlobServiceClient
import os
# Configurazione
account_name = """%BS_ACCOUNT_NAME%"""
account_key = urllib.parse.quote("""%BS_ACCOUNT_KEY%""")
container_name = """%BS_CONTAINER_NAME%"""
blob_name = """%BS_BLOB_FILE_NAME%"""
local_file_path = """%LOCAL_FILE_PATH%"""
# Crea un client del servizio blob
blob_service_client = BlobServiceClient(account_url="https://{}.blob.core.windows.net".format(account_name), credential=account_key)
# Ottieni il client del container
container_client = blob_service_client.get_container_client(container_name)
# Ottieni il client del blob (file)
blob_client = container_client.get_blob_client(blob_name)
# Scarica il blob
with open(local_file_path, "wb") as local_file:
 download_stream = blob_client.download_blob()
 local_file.write(download_stream.readall())
print "Success"

From CMD I performed the module installation either via:

  • pip install azure-storage-blob==1.5.0

  • pip install azure-storage-blob

And indeed the same code defined in PAD in Visual Studio Code works correctly.

Going to run the code via Power Automate Desktop (using both Python 2.7 or 3.4), however, I get the following error:

Traceback (most recent call last): File "<string>", line 3, in <module> ImportError: No module named azure.storage.blob

Hence the question:

  • How can I correctly import an external python module inside Power Automate Desktop so it can be used in the "Run Python Script" activity?

I tried to verify that the installation of the module via pip was successful by running the code from a different development environment, such as Visual Studio Code. And so it was.

To solve the problem, I expect that the python module should be installed in a different path in the environment or that I am missing a setting in Power Automate Desktop to indicate where to go to read the modules to be used in the scripts.

Note:

  • the same error also occurs when using modules from the standard python library, such as "json" module

Thanks in advance

asked Feb 16, 2025 at 16:32

1 Answer 1

0

Power Automate Desktop uses its own Python env, not the system one, which is causing the issue. The packages you are installing are being installed in system's python environment. To resolve the issue, you will have to install the required packages directly in PAD's python installation. So locate and activate that enviroment and do pip install azure-storage-blob.

answered Feb 16, 2025 at 18:50
Sign up to request clarification or add additional context in comments.

3 Comments

Thank you @Abdul Rafay, could you please explain me how to locate and activate the PAD's python environment? I have tried to do this but I am not sure if I have done the steps correctly. Thanks in advance
The default location is : C:\Users\{username}\AppData\Local\Programs\Power Automate Desktop\Scripts\pip.exe install azure-storage-blob
Hi, checking at the path you indicated I did not find the Script folder. So, I installed the module azure-storage-blob in the python environment, both in "C:\Python27" and "C:\Python34". However, I still get the same error when I try to use the "Run Python Script" action.

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.