Pipe is broken

Hello,

I tried to invoke code which is runing correctly in IDE, but when i try to invoke it in UiPath i receive error “Pipe is broken”. My code do not return anything so it should not be related to size of the object. Here is my python code, it is simply downloading images from api and sending via mail:

import requests
import json
import sys
import win32com.client


def my_outlook(url):
    imageAPI=url
    outlook = win32com.client.Dispatch('outlook.application')
    mail = outlook.CreateItem(0)
    mail.To = 'my@email.com'
    mail.Subject = 'Test Python API'
    mail.HTMLBody = f"<!DOCTYPE html><html><head><meta http-equiv='content-type' content='text/html; charset=ISO-8859-15'></head><body><img src={imageAPI}></body></html>"
    mail.Send()


def my_api():
    token = "XXXX-MY-TOKEN-XXX"
    api_url = "https://api.thedogapi.com/v1/images/search"
    response = requests.get(api_url,headers={'x-api-key':token},params={'size':"small"})
    #print(response.json())
    json_data = json.loads(response.text)
    print(json_data[0]['url'])
    url=json_data[0]['url']
    my_outlook(url)

my_api()



Hi @Add_Bddd,

We can start by following the article and checking these areas.

Have you had a chance to check other threads that are getting this error?

The error has occurred during the reading and writing of the files and it mainly occurs during the operations of the files.

Regards,
MY

Yes i do, nothing related to my code i can see. Is it beacuse inside code one method invoke another one?

myoutlook(url)

Hello @Add_Bddd

Can you try with Invoke python activities. Please check the below video for better understanding.
Instead of Invoke code you can use this activity.

Install the python package.

Hi @Add_Bddd,

Have you tried running it with the .bat file? If it works, we can point to the uipath side for the error.

1 Like

Hello @muhammedyuzuak

So i have tested on .bat file:

This worked correctly:

@echo off
“C:\Users\User2\PycharmProjects\untitled1\venv\Scripts\python.exe” “C:\Users\User2\PycharmProjects\untitled1\test.py”
pause

This returned error - did not found “requests” package (which im using in code):
@echo off
“C:\Users\User2\AppData\Local\Programs\Python\Python38\python.exe” “C:\Users\User2\PycharmProjects\untitled1\test.py”
pause

So now, im using "“C:\Users\User\AppData\Local\Programs\Python\Python38” in Path properties in “Python scope” and it`s returing “pipe is broken” but i cannot use “C:\Users\User2\PycharmProjects\untitled1\venv\Scripts\python.exe” as it is returning failed to initialize python engine. Im stuck :frowning:

I think the problem is with packages im using in script, and i dont know how to “link” them in the UiPath, i should have any pipe erorr as im not even working on files.

@muhammedyuzuak

Thank you, your post guided me to the problem. When i was installing package in my PyCharm IDE it was installing only localy, so there was nothing installed inside:

C:\Users\User2\AppData\Local\Programs\Python\Python38\Lib\site-packages

Therefore uipath were throwing “pipe is broken” error. I have installed packages required for project using windows command line and it installed finally packages where i wanted. Now i can run my python script. Marking as solved.

1 Like

I’m glad it’s resolved.

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