Python activity error


#61

its out, check Official feed


#62

I just installed a virtual environment in exactly the same way, pip installed pandas to the new environment, set the Python directory in UiPath to it, and my script ran without error (just importing pandas, datetime and os).

Did you activate the environment?

i.e. (the name of my environment is py36)

conda activate py36

You can disregard the references to Python 3.7 in conda info, I have the same thing:

Additionally, make sure the packages are installed:

conda list


#63

Yes activated the environment, it is all correct. Do I need to activate it from the python scope activity? Should I use pip to install instead of conda?


#65

I’m not sure if it makes a difference for installing packages, but I did pip install pandas from the Anaconda Prompt


#66

wow it finally works, so it needed to be installed with pip not conda, very odd. Maybe the update done something as well.

But massive thank you 100x @rautry you have been a great help, without you I would still be opening conda prompt. Have a good day! :grinning:


#67

Glad we got to the bottom of this! Good to know that the python environments can be a little tricky with conda and then UiPath.

Have a good one!


#68

arghhh this is so annoying I haven’t done anything since Friday, and now the script won’t load. But it was working fine before hand.


#69

If you are getting an error about the script, you probably need to check your paths. If you are using all static paths, you’ll need to double-check that everything is still in the same location.


#70

yes its something to do with paths again, but all my paths are absolute I have checked every one. I have been reading the docs and it told me to put this code in module;

import sys 
import os
sys.path.append(os.path.dirname(os.path.realpath(_file_)))
import <your module here>

But that doesn’t work too. It is really odd that this worked fine on Friday.


#71

I also asked elsewhere with python developers and they said sys.path should not be changed.


#72

Found the error it doesn’t like a special character from the Spanish language, which again is odd as one why was it working on Friday, two read_excel doesn’t mess up when running on its own.


#73

Glad you figured it out!


#74

Hi Mayur,

I’m going through similar issues. When I run a normal python script it’s perfectly running but when I use pandas or any other new module. UiPath is failing to execute the code. I would like to know how to setup environment.
When you setting up path do you me providing python path in python scope ?

I have done that still I’m facing this issue. Also, I’m using run python script activity under python scope to execute the python script.

Thanks in advance!


#75

Hi @ashoks93,

It could be a number of things. I will list them and try each of them.

  1. Do you have a virtual environment? If so provide the path to that. (It will be in the anaconda envs folder).
  2. Are you using 32-bit or 64-bit python? Make sure to change the “Target” attribute to the correct one.
  3. What version of python are you using, It cannot be python 3.7 it has to be 3.6, a friend of mine was using 2.7 and he could not use it with 64-bit so you might need to play around with what python version and target you are using.
  4. Check your code for triple quoted comments and remove them.
  5. Load python script using the “Load python” activity giving the path to the file name that you want to load. And then maybe just have a function that returns “hello world” -> “invoke python method” activity give it the function name and o/p of the load python script -> “get python object” activity convert the returned string to a .net string -> “write line” activity to see if that works, then you know your path is correct it is something to do with the code.

Give those a go, and see if any of them fixes it. If not reply back and I will see what I can do.