web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Problem when importing...
Power Automate
Answered

Problem when importing python libraries

(0) ShareShare
ReportReport
Posted on by 8

Hello!

I want to create a stream to execute a python code.
I understand that the best way to do this is to run an application, by putting the path to the .py file.

The problem is that it doesn't run... I have created a simple code where it tests where it reads an excel, and stores the value in a new document, but it doesn't create anything...
I have tried to use the option to run a python script, but as I import some library (pandas), it gives me error:
Traceback (most recent call last):
File "<string>", line 1, in <module>.
ImportError: No module named pandas

What is the best way to implement this?

The idea is to create a flow to execute a code to read excels and create new ones.

Thanks!

I have the same question (0)
  • Verified answer
    Agnius Bartninkas Profile Picture
    Most Valuable Professional on at

    The Run Python script in PAD only supports Python 2. If you are okay with that, but need some more advanced modules, you need to install Python on your machine and provide the path to the modules directory into the "Module folder paths" field under Advanced options:

    Agnius_0-1704895285486.png

     

    The default directory is usually around C:\Users\{YourUserName}\AppData\Local\Programs\Python\Python{Version}\Lib

     

    If you're trying to use a Python 3 script, or any libraries that are not supported by Python 2, this won't work however. In that case, you will in fact need to run the .py script via Run application or a PowerShell script for example.

     

    As to why it doesn't work for you when you use Run application, have you actually verified that your script works? Have you tried simply manually running the .py file? Does your operating system actually allows running .py files? Some Windows systems (especially organization-managed machines) usually do not allow it.

    -------------------------------------------------------------------------
    If I have answered your question, please mark it as the preferred solution. If you like my response, please give it a Thumbs Up.

    I also provide paid consultancy and development services using Power Automate. If you're interested, DM me and we can discuss it.

  • AndoniA Profile Picture
    8 on at

    Yes, manually the code works tested with normal python editors.
    My version is 3.10.10, so using python version 2 would not work for me.

    I've tried using run app, it opens the .py with VS Code, and with the option to click, I hit play and the code runs.

    I understand that the most comfortable option is to use PowerShell...

  • Agnius Bartninkas Profile Picture
    Most Valuable Professional on at

    Are you allowed to run .py files? Have you tried simply double-clicking it and seeing if it runs?

     

  • AndoniA Profile Picture
    8 on at

    Yes, on my computer I can run .py normally, with Spyder and VsCode.

    I have tried two flows:
    - If I use power shell with:
    set variable (pathPython (where python.exe is))
    set variable (pathScript (where .py is))
    powershell script ( %pathPython% %pathScript% )
    --> it doesn't run anything.

    - The only way I've been able to do it is:
    running app (.py)
    click on the window interface (run button on vscode)
    -->run the .py and it works

    Is there any other option to not have to use the window click?

     

  • Agnius Bartninkas Profile Picture
    Most Valuable Professional on at

    This is because you've set VSCode to be the default app for opening .py files. Either make Python.exe do it, or use python.exe as the app you run via Run application and provide the path to the .py file as the argument.

    -------------------------------------------------------------------------
    If I have answered your question, please mark it as the preferred solution. If you like my response, please give it a Thumbs Up.

    I also provide paid consultancy and development services using Power Automate. If you're interested, DM me and we can discuss it.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
David_MA Profile Picture

David_MA 223 Super User 2025 Season 2

#2
Expiscornovus Profile Picture

Expiscornovus 205 Most Valuable Professional

#3
harshdeol Profile Picture

harshdeol 167 Moderator

Last 30 days Overall leaderboard