Jump to content

How to trigger python script from spotfire (to run via cmd). Not IronPython.


Recommended Posts

I have a Python script that uses libraries unavailable in IronPython. I would like to trigger the python script to run in a python environment external to spotfire. Typically from R I can fire off a script like this using the following code:

input_fun_str = paste("Path_to_env\python Path_to_scripttest_function.py", arg1)

system("cmd.exe", input=input_fun_str)

This did not work for me in TERR unfortunatley. Is there a method to trigger a python script in an external environment from spotfire

Thanks

Link to comment
Share on other sites

What version of TERR are you using. With TERR-4.5.0, on a Windows machine with Continuum/Anaconda's python installed, I get

 

> cat("print(1+2/3)n", file=tf <- tempfile())

> result <- system(paste("C:\Users\wdunlap\AppData\Local\Continuum\anaconda3\pkgs\python-3.6.4-h0c2934d_2\python.exe", normalizePath(tf)), intern=TRUE)

> result

[1] "1.6666666666666665"

Link to comment
Share on other sites

It is possible to execute C Python from IronPython. Here's an example:

from System.Diagnostics import Process

from System.Diagnostics import ProcessStartInfo

from System.Diagnostics import ProcessWindowStyle

process = Process()

startInfo = ProcessStartInfo()

startInfo.WindowStyle = ProcessWindowStyle.Hidden

startInfo.FileName = "C:\python\python.exe"

startInfo.Arguments = "test_function.py"

process.StartInfo = startInfo

process.Start()

Link to comment
Share on other sites

  • 4 months later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...