# Invoke Python method Argument Error

**URL:** <https://forum.uipath.com/t/invoke-python-method-argument-error/129854>\
**Category:** Help\
**Tags:** python, excel, error, activities\
**Created:** [July 1, 2019, 4:35pm UTC](https://forum.uipath.com/t/invoke-python-method-argument-error/129854 "2019-07-01T16:35:51Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![brandon\_araya](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/brandon_araya/32/54541_2.png) [@brandon\_araya](https://forum.uipath.com/u/brandon_araya)\
**Post date:** [July 1, 2019, 4:35pm UTC](https://forum.uipath.com/t/invoke-python-method-argument-error/129854/1 "2019-07-01T16:35:51Z")

</div>

I guys,

I have this python method to write tables in excel.

> def create\_pivot\_table(Dir):  
> file1 = open(r’C:\Users\*\*\myfile2.txt’,“w”)  
> file1.write(Dir)  
> file1.close()  
> df = pd.read\_excel(open(Dir,‘rb’),“Hoja1”)  
> pivot\_baja=df[df[‘Texto’].str.contains(“BAJA”)==True].pivot\_table(index=‘Cuenta’, values=’ Importe en ML’, aggfunc=‘sum’)  
> pivot\_Aplica=df[df[‘Texto’].str.contains(“Aplica”)==True].pivot\_table(index=‘Cuenta’, values=’ Importe en ML’, aggfunc=‘sum’)  
> pivot\_add=df[(df[‘Texto’].str.contains(“BAJA”)==False) & (df[‘Texto’].str.contains(“Aplica”)==False) & (df[‘Texto’].str.contains(“baja”)==False) ].pivot\_table(index=‘Cuenta’, values=’ Importe en ML’, aggfunc=‘sum’)  
> book = load\_workbook(dir)  
> writer = pd.ExcelWriter(dir, engine=‘openpyxl’)  
> writer.book=book  
> pivot\_Aplica.to\_excel(writer, sheet\_name=“Aplicaciones”)  
> pivot\_add.to\_excel(writer,sheet\_name=“Adiciones”)  
> pivot\_baja.to\_excel(writer, sheet\_name=“bajas”)  
> writer.save()  
> writer.close()

and the activity is giving me this exception:

"RemoteException wrapping System.InvalidOperationException: Error invoking Python method —\> RemoteException wrapping System.ServiceModel.FaultException`1[[System.ServiceModel.ExceptionDetail, System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]: TypeError : expected str, bytes or os.PathLike object, not builtin\_function\_or\_method "

the argument of the activity is {“workbook.xlsx”}.

when i use the script by its own i don’t have any problems

---

<div class="post-metadata">

**Author:** ![brandon\_araya](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/brandon_araya/32/54541_2.png) [@brandon\_araya](https://forum.uipath.com/u/brandon_araya)\
**Post date:** [July 1, 2019, 5:09pm UTC](https://forum.uipath.com/t/invoke-python-method-argument-error/129854/2 "2019-07-01T17:09:15Z")

</div>

Solve it, the lower key dir variables where the problem

---

<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:** [July 4, 2019, 5:09pm UTC](https://forum.uipath.com/t/invoke-python-method-argument-error/129854/3 "2019-07-04T17:09:19Z")

</div>

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