cancel
Showing results for 
Search instead for 
Did you mean: 

Running Python scripts via Code block

JohanSörman
Level 5
Hello,

I have a use case where I need to excecute a python script. 
My question is if you need to have python onboarded or IronPython as this example uses:
Code Stages (higherlogicdownload.s3-external-1.amazonaws.com)

var py = Python.CreateEngine();
string scriptpath = @"pathwaytoscript.py";
if (File.Exists(scriptpath))
	{
		py.ExecuteFile(scriptpath);
	}​

The error I'm getting when trying to run the action: 

ERROR: Internal : Could not execute code stage because exception thrown by code stage: Could not load file or assembly 'IronPython, Version=2.7.11.0, Culture=neutral, PublicKeyToken=7f709c5b713576e1' or one of its dependencies. The system cannot find the file specified.

Is it required to have Python installed/onboarded to the VM?

The IronPython DLL is placed in Blue Prism install folder

22808.png

------------------------------
Johan Sörman
DevOps Engineer, Senior RPA Developer
Telia Company
Sweden
------------------------------
4 REPLIES 4

Hi Johan,

I haven't tried debugging the issue related to Iron Python you mentioned but wanted to let you know incase you are ok with not using Iron Python and just directly triggering the python code, then there is a script execution vbo available on DX 

https://digitalexchange.blueprism.com/dx/entry/3439/solution/blue-prism---script-execution-vbo-2 

You will need to have python installed to use this asset.

------------------------------
Shashank Kumar
DX Integrations Partner Consultant
Blue Prism
Singapore
+6581326707
------------------------------

Hello Shashank, 

I have imported this VBO but wanted initially try run my script without having to install python but perhaps we'll have to do that.


------------------------------
Johan Sörman
DevOps Engineer, Senior RPA Developer
Telia Company
Sweden
------------------------------

ewilson
Staff
Staff
@Johan Sörman,

This type of error can be a real pain to troubleshoot. Sometimes, the issue is the specific DLL mentioned in the error message. Other times, the error is related to a DLL that top-level DLL depends on. So, troubleshooting this can become a bit of a rabbit hole.

You show that the IronPython.dll library is listed in your references, and you stated that you have deployed it within the Blue Prism Automate folder on your machine. Did you just copy the DLLs from another machine or did you actually install IronPython on the machine? If you just copied the DLLs from another machine I'd say you probably want to try actually installing IronPython on it.

If that doesn't address the issue, then it's likely that you're missing a dependent DLL. To troubleshoot that you'll probably need to grab a copy of the Dependency Walker utility in order to see what other files are being referenced.

Cheers,


------------------------------
Eric Wilson
Director, Integrations and Enablement
Blue Prism Digital Exchange
------------------------------

Hi Eric,

Yes I copied the files from my local machine to the VM. So it might just be that.
I'll keep that in mind for the future.

However I found a workaround and got option 1 working (running the file via the Utility - Env VBO). 
Otherwise was my goal to have Python installed on our VMs and run it that way.

The solution I got working for anyone finding this thread in the future (hi), was this:

GitHub - BlueprismWorld/Run-python-in-Blueprism

------------------------------
Johan Sörman
DevOps Engineer, Senior RPA Developer
Telia Company
Sweden
------------------------------