Execute Project in Python Interactive

Oct 3, 2013 at 10:01 PM
When I want to run my project in the Interactive window I open the project's Startup file in the editor, select all (CTRL+A) and then hit CTRL+E, CTRL+E. This works well but it would be more convenient to have a menu item or a key combination that could do the same.

I thought the menu item Debug/Execute Project in Python Interactive would do exactly this. However, if I restart the IPython Interactive and then get a In [1]: prompt and then click on the menu item Debug/Execute Project in Python Interactive nothing happens, except that I get the following message before (!) the In [1]: prompt:

Resetting execution engine
The Python REPL process has exited
Running C:\Files\Python\run_fractal.py
The Python REPL process has exited

(run_fractal.py is the name of my project's Startup file)

Am I trying to use this menu item in an incorrect way?

Thanks for any insights.
Coordinator
Oct 3, 2013 at 10:11 PM
The REPL process shouldn't be exiting at the end of your script - are you calling sys.exit() anywhere? (It should be resetting at the start - we need to clear up previous state. If you don't want to clear it, you can import your script, which will run any code in it.)

The idea is that your program will run from start to end, and then leave all its variables in the interactive window so you can review them. (It will reset the state each time you start.)
Coordinator
Oct 3, 2013 at 10:21 PM
also note that there are two menu options:

1) Tools/Python Tools/send to interactive

2) Tools/Python Tools/execute project in python interactive

the 2nd one resets, the 1st one just copy/pastes into the existing interactive window.
Oct 3, 2013 at 10:23 PM
I created a file with a single line of code:

print('This is a test')

and then clicked on Debug/Execute Project in Python Interactive. The behavior was the same as before.

I just noticed that if after I do this I enter something at the prompt, for example,

In [1]: 1+1 <Enter>

nothing happens and the Interactive Window becomes unresponsive. Unless I restart the Interactive Window by clicking on the blue arrow no key combination has any effect (what I type is not displayed).
Coordinator
Oct 3, 2013 at 10:26 PM
What version of Python are you using?
Coordinator
Oct 3, 2013 at 10:31 PM
Debug/Execute Proj in Python Interactive executes your current startup file (bolded). if you have selected text and and choose Debug/Execute in debug interactive, the text selection is ignored. you should use Tools/Python tools/send to interactive. (just stating this in case there was confusion).
Oct 7, 2013 at 7:18 PM
I am using Python version 3.3.2.

My problem is that

"Debug/Execute Proj in Python Interactive executes your current startup file (bolded)."

does not happen in my system.
Coordinator
Oct 7, 2013 at 10:06 PM
Edited Oct 7, 2013 at 10:07 PM
interesting. i just tried it again & can't repro -

you are saying that with a file set as the default (bolded), when you click Debug/Execute in interactive, the startup file does not get executed? if so, does anything get run, or something other than the startup file?

here are my unsuccessful attempts at repro'ing:


Project w two files, woof.py & meow.py, with meow.py being the startup file:

1) Debug/Execute project in Interactive --- prints meow as expected:

Image

2) ctrl-A to select all, ctrl-E-E to send to Interactive -- prints woof as expected:

Image

3) repeat of 1) above, just thru Tools/Python Tools/Execute proj in Interactive again -- prints meow as expected:

Image

4) set Interactive mode to IPython, Debug/Execute project in Interactive --- prints meow as expected:

Image

can you do a simple repro of your issue ? thx.
Apr 25, 2015 at 10:23 AM
Sorry for bumping an old thread, but I'm having the same problem. I'm using VIsual Studio Professional 2013, Python Tools for Visual Studio 2.1, iPython 2.3.1, and Python 3.4.

Test case: test.py contains one line, print('Foo'). I open this in Visual Studio (no associated project) and select Debug - Execute File in Python Interactive.
It doesn't seem to run the code, and outputs this in the interactive window:
Resetting execution engine
Running C:\T\test.py
The Python REPL process has exited
The Python REPL process has exited

In [1]:

When I select all and send to interactive (Ctrl+E, Ctrl+E) it does print Foo.

Same problem exists when creating a solution for the file.

However, when I change interactive mode from iPython to Standard, it works:
Resetting execution engine
Running C:\T\test.py
The Python REPL process has exited
Foo
Is there any way to get this working with iPython too?

Execute File in Python Interactive (iPython):
Image

Send to Interactive (iPython):
Image

Execute File in Python Interactive (Standard):
Image
Coordinator
Apr 27, 2015 at 6:51 PM
Hi,

We have moved our operations to a new page at github. Please recreate your discussion or issue at our page there.

Thanks,
PTVS Team