Hung Huynh Posted July 19, 2019 Share Posted July 19, 2019 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 More sharing options...
Shandilya Peddi Posted July 19, 2019 Share Posted July 19, 2019 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 More sharing options...
Hung Huynh Posted July 19, 2019 Author Share Posted July 19, 2019 startInfo.Arguments = "C:UsersDocumentshello.py" Here is my current path. Does the python script file need to be in the same folder as the executable Link to comment Share on other sites More sharing options...
Hung Huynh Posted July 19, 2019 Author Share Posted July 19, 2019 I can see my python cmd prompt running however I do not see anything being printed on the output dialog for Spotfire. In my py script I have a print("Success") at the end just to verify. Link to comment Share on other sites More sharing options...
Shandilya Peddi Posted July 22, 2019 Share Posted July 22, 2019 Try to type in the folder path and see if it makes a difference. This is one thing i noticed when working on the script Link to comment Share on other sites More sharing options...
Hung Huynh Posted July 24, 2019 Author Share Posted July 24, 2019 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 SpotfirestartInfo.FileName = "C:Anaconda3python.exe"startInfo.Arguments = "C:Anaconda3BubbleSort.py"However nothing shows on the output console Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now