cancel
Showing results for 
Search instead for 
Did you mean: 

Python Scrits

johnambrosiano
Champ in-the-making
Champ in-the-making
What's the trick for getting Python scripts enabled in script tasks. I set the scriptFormat value to "python" and it tells me "Can't find scripting engine for 'python'"
14 REPLIES 14

vasile_dirla
Star Contributor
Star Contributor
not really unsupported, (if you have the proper library which is able to interpret python it's supported)
scripting it's interpreted by an external library so it has nothing to do with Activiti.

Since you are interested by python support you said would like to see that written in the documentation.
but as you know there could be hundreds of script engines in the world what will be if we'll write about all of them ?

Imagine that you could develop your own scripting with support for JSR 233 and you'll be able to use it in java.

see this: https://www.jcp.org/en/jsr/detail?id=223

johnambrosiano
Champ in-the-making
Champ in-the-making
So it looks like Python is pretty much unsupported at this time. Should probably put that in the documentation somewhere.

I'm not dedicated to Jython, by the way. Just seemed like that was what JSR 223 led me to believe, i.e., it says the interpreter for Python is backed by Jython - if I read it right.

Do you know if there's a workaround, like getting Groovy to call Python or something?

johnambrosiano
Champ in-the-making
Champ in-the-making
Thanks for your example, by the way. I don't mean to seem ungrateful.

I get your point about scripting not necessarily being the responsibility of Activiti, but Groovy is transparently usable and has a clear example in the user guide. Python is the #1 scripting language in the world, as for instance suggested here http://www.drdobbs.com/jvm/the-rise-and-fall-of-languages-in-2013/240165192

Honestly, I'm not clear on how JSR 223 is supported generally. Perhaps it would help if I learned a bit about that. On Activiti's end, a section in the user guide on the general topic of getting interpreters for the top scripting languages to work with Activiti might be really helpful. For example, my understanding is that Javascript should work out of the box in Activiti like Groovy, but I couldn't get that one to work for me either. Same "cannot find interpreter" error.

vasile_dirla
Star Contributor
Star Contributor
this is how you could use a scripting engine form a java app.

<code>
ScriptEngine engine = new ScriptEngineManager().getEngineByName("python");
        engine.put("a", "1234");
        engine.eval("print a");
</code>

this will work if you have in the classpath the proper jar.

johnambrosiano
Champ in-the-making
Champ in-the-making
Excellent. Thanks.