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".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
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".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
Share Improve this question asked Feb 16 at 16:32 Gabriele RodonòGabriele Rodonò 11 bronze badge New contributor Gabriele Rodonò is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.1 Answer
Reset to default 0Power 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.