# How to invoke a python script that read excel file

**URL:** <https://forum.uipath.com/t/how-to-invoke-a-python-script-that-read-excel-file/872353>\
**Category:** Studio\
**Tags:** activities-panel, question, studio, python, excel, activities\
**Created:** [February 14, 2025, 1:50pm UTC](https://forum.uipath.com/t/how-to-invoke-a-python-script-that-read-excel-file/872353 "2025-02-14T13:50:33Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gbenga\_Odelade](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/gbenga_odelade/32/211229_2.png) [@Gbenga\_Odelade](https://forum.uipath.com/u/Gbenga_Odelade)\
**Post date:** [February 14, 2025, 1:50pm UTC](https://forum.uipath.com/t/how-to-invoke-a-python-script-that-read-excel-file/872353/1 "2025-02-14T13:50:33Z")

</div>

Good day all,

Please, I am having an error with Invoke Python Method activity. I was able to load my python script but my bot is throwing an error at Invoke Python Method activity.  
Below is the error message I got.  
**Invoke Python Method: One or more errors occurred.**  
Below is my python script:  
import pandas as pd

def main(filePath):  
df = pd.read\_excel(filePath)  
with pd.ExcelWriter(filePath, mode=‘a’, engine=‘openpyxl’, if\_sheet\_exists=‘new’) as writer:  
df.to\_excel(writer, sheet\_name=‘Sheet2’, index=False)

Note: filePath is my input parameter I am passing in.

---

<div class="post-metadata">

**Author:** ![Anil\_G](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/anil_g/32/524291_2.png) [@Anil\_G](https://forum.uipath.com/u/Anil_G)\
**Post date:** [February 14, 2025, 2:37pm UTC](https://forum.uipath.com/t/how-to-invoke-a-python-script-that-read-excel-file/872353/3 "2025-02-14T14:37:19Z")

</div>

@Gbenga_Odelade

Please open the locals panel in debug mode and expand the exception details you would see more details of what exactly is the issue and from there we can take next steps based on the error you need

Cheers

---

<div class="post-metadata">

**Author:** ![postwick](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/postwick/32/227083_2.png) [@postwick](https://forum.uipath.com/u/postwick)\
**Post date:** [February 14, 2025, 5:13pm UTC](https://forum.uipath.com/t/how-to-invoke-a-python-script-that-read-excel-file/872353/4 "2025-02-14T17:13:01Z")

</div>

Out of curiosity why are you doing this instead of just using the activities for reading an Excel file? They’re simple.

---

<div class="post-metadata">

**Author:** ![JuanCarvajalino](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/juancarvajalino/32/512481_2.png) [@JuanCarvajalino](https://forum.uipath.com/u/JuanCarvajalino)\
**Post date:** [February 18, 2025, 12:59am UTC](https://forum.uipath.com/t/how-to-invoke-a-python-script-that-read-excel-file/872353/5 "2025-02-18T00:59:44Z")

</div>

Check if pandas is installed in the machine the bot is running.

---

<div class="post-metadata">

**Author:** ![Gbenga\_Odelade](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/gbenga_odelade/32/211229_2.png) [@Gbenga\_Odelade](https://forum.uipath.com/u/Gbenga_Odelade)\
**Post date:** [March 4, 2025, 9:13pm UTC](https://forum.uipath.com/t/how-to-invoke-a-python-script-that-read-excel-file/872353/6 "2025-03-04T21:13:26Z")

</div>

Thanks all. The issue has been resolved.  
I had to install openpyxl.

---

<div class="post-metadata">

**Author:** ![system](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/system/32/182466_2.png) [@system](https://forum.uipath.com/u/system)\
**Post date:** [March 7, 2025, 9:13pm UTC](https://forum.uipath.com/t/how-to-invoke-a-python-script-that-read-excel-file/872353/7 "2025-03-07T21:13:37Z")

</div>

Closed on March 7, 2025, 9:13pm UTC

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.
