Invoke python method is not working. in my python script i have below mentioned library
from sklearn.feature_extraction.text import TfidfVectorizer
from sklearn.metrics.pairwise import cosine_similarity
for this library i am getting error
error message:
Source: Invoke Python Method
Message: Pipe is broken.
Exception Type: System.IO.IOException
System.IO.IOException: Pipe is broken. at System.IO.Pipes.PipeStream.CheckWriteOperations()
at System.IO.Pipes.PipeStream.Flush()
at System.IO.StreamWriter.Flush(Boolean flushStream, Boolean flushEncoder)
at System.IO.StreamWriter.set_AutoFlush(Boolean value)
at UiPath.Python.Service.PythonProxy.RequestAsync(PythonRequest request, CancellationToken ct)
at UiPath.Python.Service.PythonProxy.Shutdown()
at UiPath.Python.Impl.OutOfProcessEngine.Release()
at UiPath.Python.Activities.PythonScope.Cleanup()
at UiPath.Python.Activities.PythonScope.OnFaulted(NativeActivityFaultContext faultContext, Exception propagatedException, ActivityInstance propagatedFrom)
at System.Activities.Runtime.FaultCallbackWrapper.Invoke(NativeActivityFaultContext faultContext, Exception propagatedException, ActivityInstance propagatedFrom)
at System.Activities.Runtime.FaultCallbackWrapper.FaultWorkItem.Execute(ActivityExecutor executor, BookmarkManager bookmarkManager)
I added the system variable for both python and pip also. still i am getting error
My python script:
import pandas as pd
import spacy
from sklearn.feature_extraction.text import TfidfVectorizer
from sklearn.metrics.pairwise import cosine_similarity
import sys
def run_123(text):
return " Hi " + text
if name == “main”:
run(sys.argv[1])
Error:
I am able to run simple programs in Invoke Python method. In above program i am getting error in import statements. I tested this same code locally it is working fine but it is not working in invoke python code.
It is working in Shell but it is not working in invoke python code.
I think i am facing issue with below library
from sklearn.feature_extraction.text import TfidfVectorizer
from sklearn.metrics.pairwise import cosine_similarity
Hi @BNK
Here is my suggestion, if the Python invoke method does not work.
Open the cmd prompt and change the directory path to the python folder “cd /d C:\Program Files\Python310” and enter python.py script path and also you can add arguments at the end of the line, test it, and if works Use UiPath activities for cmd prompt automation in that you can able to send the change directory path, python.py path, and any argument values.