Jump to content

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


Hung Huynh

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. I currently have this however it doesn't do anything.

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:Anaconda3python.exe"

startInfo.Arguments = "BubbleSort.py"

process.StartInfo = startInfo

process.Start()

Link to comment
Share on other sites

I used the below code and seems to work as expected. Can you try to specify the full file path for "BubbleSort.py"

from System.Diagnostics import Process

from System.Diagnostics import ProcessStartInfo

from System.Diagnostics import ProcessWindowStyle

 

#process = Process()

startInfo = ProcessStartInfo()

startInfo.WindowStyle = ProcessWindowStyle.Normal

startInfo.FileName = "C:Python27python.exe"

startInfo.Arguments = "C:Python27hello.py"

process.StartInfo = startInfo

 

# to get the output into spotfire

startInfo.RedirectStandardOutput = True;

startInfo.RedirectStandardError = True;

startInfo.UseShellExecute = False;

 

#start the process

reg=Process.Start(startInfo)

#print the output

myOutput=reg.StandardOutput

print myOutput.ReadToEnd()

Link to comment
Share on other sites

Good Morning,

 

I placed the py script in the same folder and ran it on Spotfire. I see the cmd prompt running in the background but no output being displayed on Spotfire

startInfo.FileName = "C:Anaconda3python.exe"startInfo.Arguments = "C:Anaconda3BubbleSort.py"

However nothing shows on the output console

Link to comment
Share on other sites

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...