Run script from external app within spyder

316 views
Skip to first unread message

sebastian06

unread,
Oct 25, 2014, 5:43:33 AM10/25/14
to spyd...@googlegroups.com
Hi,

I have a python script that uses the python wrapper for the BioFormats library. It works fine for imorting my image data sets, which show up in Spyder as a numpy array.

Now I want uo start this script from an external application within Spyder, because I want to process the array afterwards. Just starting a script is easy, but I do not know how to start it within Spyder from an external app. What would be the easiest way to do this?  

Cheers, Sebi


 

Carlos Córdoba

unread,
Oct 25, 2014, 1:49:44 PM10/25/14
to spyd...@googlegroups.com
Hi,

I'm not sure if I exactly follow you. How does this external app start your script? Do you really need it to do it? I mean, the easiest way would be to switch your external app for Spyder itself but it's a bit hard to give you further advice without knowing more details :-)

Cheers,
Carlos

El 25/10/14 a las 04:43, sebastian06 escribió:
--
You received this message because you are subscribed to the Google Groups "spyder" group.
To unsubscribe from this group and stop receiving emails from it, send an email to spyderlib+...@googlegroups.com.
To post to this group, send email to spyd...@googlegroups.com.
Visit this group at http://groups.google.com/group/spyderlib.
For more options, visit https://groups.google.com/d/optout.

sebastian06

unread,
Oct 26, 2014, 6:16:12 AM10/26/14
to spyd...@googlegroups.com
Hi Carlos,

sorry for being to "very precise".

Of course the easiest way is to switch manually to Spyder and run the script. But what I am aiming for is an automated workflow. So I will try to explain this in more detail.

Our Microscope Control Software (ZEN Blue) is written in C# and used IronPython as the internal scripting language. That is the place where the user can automate their experiments. And this is where I wnat to start a "normal" python script within Spyder. Usually I start python scripts like this from inside the ZEN Blue software:

-------------------------IRON PYTHON SCRIPT IN ZEN BLUE  (just parts)   ------------------------
import clr
from System.Diagnostics import Process
...

# this is the location of the script use to plot the data
# use this version for a general approach -->; pass filename, X-column and Y-column to plot directly from the macro
script1 = r'C:\My Scripts\PlotData_Example.py' # this is a "normal" python script
   
# those are the parameters - filename, (X-Column and Y-Column)
# this one for the general approach
params1 = ' -f ' + csvfile + ' -x 2 -y 0 -r 2'
   
# start the data display script as an external application
app1 = Process();
app1.StartInfo.FileName = script1
app1.StartInfo.Arguments = params1
app1.Start()

----------------------------------------------------------------------------------

Since python script *.py are associated with python.exe the script will be started easily this way. But when I do this the data (numpy array, ...) are lost unless the script explicitly saves the data somewhere. but what I would like to do is starting the same script from our Software within Spyder. This way I would not have to save the data and reload again, because they would be available within Spyder for further processing.
For me (as a non-expert) the question is how to start my python Script within the active Sypder python or Ipython console. But I do not know yet, how to do it or even if this is possible at all.

I hope this explains the workflow a bit better.

Cheers,  Sebi

sebastian06

unread,
Oct 26, 2014, 10:28:07 AM10/26/14
to spyd...@googlegroups.com
Hi Carlos,

of course I meant "Sorry, for being not precise enough .... :)"

Sebi

sebastian06

unread,
Nov 3, 2014, 6:58:30 AM11/3/14
to spyd...@googlegroups.com
Hi are there any new ideas on this topic yet?

Sebi

Adrian Klaver

unread,
Nov 3, 2014, 6:28:15 PM11/3/14
to spyd...@googlegroups.com
On 11/03/2014 03:58 AM, sebastian06 wrote:
> Hi are there any new ideas on this topic yet?

As I understand it, what you want is access to the data in a console.
Not sure that you necessarily need to crank Spyder for that. Seems what
you are looking for is covered by embedded IPython:

http://ipython.org/ipython-doc/dev/interactive/reference.html#embedding-ipython
--
Adrian Klaver
adrian...@aklaver.com

Carlos Córdoba

unread,
Nov 3, 2014, 7:00:30 PM11/3/14
to spyd...@googlegroups.com
Hi Sebi,

I think it's not possible to do what you're asking for. The reason is you're using IronPython, which can't be used by Spyder to run files. You could try to make it work by changing Spyder interpreter in

    Tools > Preferences > Console > Advanced Settings > Python executable > Use the following Python interpreter

and selecting the python.exe file you're using to run your scripts. But I really doubt it will work.

Sorry,
Carlos

El 03/11/14 a las 06:58, sebastian06 escribió:
--

sebastian06

unread,
Nov 4, 2014, 9:33:50 AM11/4/14
to spyd...@googlegroups.com
Hi Carlos,

I do not want to run an IronPython Script by Spyder itself. The plan is to start a "normal" python script (which I usually run from within spyder). This works fine except for the fact, that this normal script is started inside normal python console.
But ideal would be that the "normal" python scripts starts within Spyder, when called from my IronPython script.

Does this makes sense to you?

Sebi

sebastian06

unread,
Nov 4, 2014, 9:42:33 AM11/4/14
to spyd...@googlegroups.com
Hi Adrian,

I think this does not work from IronPython unfortunately ...

Cheers,  Sebi

Adrian Klaver

unread,
Nov 4, 2014, 10:44:03 AM11/4/14
to spyd...@googlegroups.com
On 11/04/2014 06:42 AM, sebastian06 wrote:
> Hi Adrian,
>
> I think this does not work from IronPython unfortunately ...

Well it is supposed to, with a little work:):

https://github.com/ipython/ipython/wiki/Frequently-asked-questions#q-can-ipython-run-under-ironpython
Reply all
Reply to author
Forward
0 new messages