Load Python Script: One or more errors occurred

Hi, I’m a new user for UIPath,

In “Main.xaml” here in my attachment, I’m trying to load a python script, and I have this error “Load Python Script: One or more errors occurred.”

How can I overcome this? Seek help please

text-summarizer.zip (3.8 KB)

Hi @edang,

Could you share a printscreen of files and folder you have in “C:\Users\edang\anaconda3\envs\mldds3”?

Also, kindly share more details about the exception

In my case, in “Path” input field of Python Scope activity I am using “C:\Python”

And I have these files and folder inside of it:

exception_info.zip (808.6 KB)
Thank you Gustavo! for taking a look,

i attached a printscreen of error message displayed in UIPath Studio.
I also attached a printscreen of the file folder containing the python executable

I was reading another post in UIpath forum:
How to run Python Script

In this post, Palaniyappan provided a sample UIPath process “PythonActivitiesTest” which loads a simple python script. I had successfully run this sample UIPath process using my environment in "C:\Users\edang\anaconda3\envs\mldds3”…

Seek advice…

Hi @edang,

Let’s test something…

To make sure it is a general problem, create a simple .py file. Something like this:

def test():
 return 123

Then, reference this new file instead of the other one (text-summarizer.py). But use the same project you were working on.

If it works, there is something wrong in text-summarizer.py

If it doesn’t, the error is something general.

Also, make sure you have python 3.6.X version installed

Yes, the version i’m using is 3.6.10

Hi the simple test.py script works for my python enviromment.

The ‘text-summarizer.py’ script works independently without using UIPath. This script is actually from this here: Understand Text Summarization
So i think it is well tested to work

So i guess the issue is related around loading of Python Script in UIPath Studio…

Hi @edang,

Have you tried to load this test.py in UiPath Studio (same project you were working on)?

Yes, I was able to load ‘test.py’ successfully in UIPath Studio. It runs ok too.

Hi @edang,

Got it…

Now, let’s change our test.py file:

#!/usr/bin/env python
# coding: utf-8
import nltk
from nltk.corpus import stopwords
from nltk.cluster.util import cosine_distance
import numpy as np
import networkx as nx

def test():
 return 123

Then, test it again in same UiPath project as before, please.

Now, if it doesn’t load the script properly, we found where the error is going on… importing dependencies.

If my guess is confirmed, let me know and I’ll show you the next steps.

Thanks

Hi Gustavo,
Haha :slight_smile: I faced the same error from UIPath Studio when I try to load the updated ‘test.py’

FYI I can run text-summarizer.py successfully using my python environment (without UIPath Studio use), so my python environment have the required python libraries

Hi @edang,

So, your error is related to Python project dependences in UiPath Studio. Because if you run test.py using your Python environment it works. Also, if you delete import rows, test.py works in UiPath Studio too.

Let’s say this python project’s dependencies aren’t visible to your UiPath project.

Instead of copying your .py file from Python project and pasting it in your UiPathStudio, try to indicate .py original path. I mean, it’s located inside your Python project path. Example: C:/Users/Gustavo/PycharmProjects/TestProject/test.py

This can work because in that directory the environment is set and has everything you need to run.

Please, try it and let me know.

Hi Gustavo, no change…

i had actually placed both in the same folder:

  • UIPath script (which loads the python script)
  • ‘test.py’

In this folder:

  • With the right python environment containing necessary dependencies loaded in Pycharm, i was able to execute ‘test.py’ in this folder

I reduce the number of ‘imports’ in ‘test.py’ to just a single import to use a popular/widely used Numpy library. UIPath can’t load this simplified script…

Hi @edang,

Got it :frowning:

I faced this same problem when I was working on a project which loads a .py file with “imports”, but honestly I can’t remember now how I solved it.

I remember I changed Windows environment variables, pointing “Path” variable to Python\ and Python\Scripts\ paths, as you can see in image below.

Perhaps, that’s what makes Python installed dependencies “visible” to UiPath projects.

Try this, please.

in your case, you’ll use C:\Users\edang\anaconda3\envs\mldds3\ and C:\Users\edang\anaconda3\envs\mldds3\Scripts\

Hi Gustavo, after adding to Windows enviroment variable path, no change… Same error

This diagram shows the full exception error message

Hi @edang,

I saw the exception. It’s about .py dependencies.

They need to be accessible to UiPath.

Try to open PyCharm > open terminal > go to your UiPath project folder > type pip show numpy.

Does it return something?

Hi Gustavo, Yes it does show:

Hi edang,

I’m running out of ideas, sorry :frowning:

We would need to connect to try to solve this problem.

If you want, send me a private message.

Hi @edang

Could you double check the below?

The problem is related to incorrect setup of the Python environment.

Make sure the Python version used has all the required packages installed, the working folder is set to the folder that keeps all the resources that are used in the Python script using relative paths - to the working folder - and the script is referenced to the full path of the script in Load script.

A test that verifies that everything is set up right is to run the script from windows command prompt as “python.exe script.py” where script.py is the script used in the project.