PTVS icon indicating copy to clipboard operation
PTVS copied to clipboard

Interactive Window not working or displaying output

Open cwebster-99 opened this issue 1 year ago • 6 comments

Received the following bug report from our docs team.

I’m running into an error right away when I try to repro the steps in the article.

I’m using Python 3.11 64-bit and I have the ipython and matplotlib libraries installed.

When I start the Interactive Window with the Use IPython interactive mode setting, I get the following error: image

I tried to repro the steps for an Anaconda installation, and the output isn’t as expected.

After entering the code into the Interactive Window, an inline graph should display. In my test, no graph displays:

image

--- OR ---

image

I tried entering the code as a block input at a single prompt and also line-by-line. Neither method produced a graph or error message. The window just displays a subsequent prompt.

Here’s what the article says: image

When I run the longer code straight from Visual Studio, the program opens a console window that simply says, Press any key to continue, which closes the window. No graph displays.

Here’s what the article says: image

cwebster-99 avatar Apr 09 '24 18:04 cwebster-99

Another interactive window issue. https://github.com/microsoft/PTVS/issues/7968

StellaHuang95 avatar Aug 13 '24 21:08 StellaHuang95

I am experiencing the same issue with a brand new installation of Visual Studio Professional 2022 (64 bit) version 17.11.4 under Windows 11.

I have the default Python 3.12.7 environment installed. When I try to use the Python interactive windows I have type $help and get keywords. However when I type anything to be interpreted like Print("hello world"), or 3+5 iI see a spinning wheel and it hangs. It never recovers.

I have no issue doing the same thing from Windows Command Prompt. It works OK there.

paulwitschey avatar Oct 06 '24 09:10 paulwitschey

This issue also reproduced on Python3.13 on VS 17.14.0 Preview 7.0 [36109.1.d17.14] Image

linette-zyy avatar May 12 '25 06:05 linette-zyy

Ok so I was able to repro this. There seem to be two problems going on here. The first is IPython.kernel not being found. In order to get past this, you have to run BOTH of these commands in your active environment:

pip install IPython
pip install ipykernel

After running these, the interactive window will no longer print the error message about not being able to find IPython.kernel. Obviously if you're using conda, you need to do conda install instead of pip install

I am also able to repro the second issue, which is the graphs not appearing. I do see output though, not just another prompt:

In [5]: plt.plot(x, y, 'r', x, x ** 3, 'g', x, x ** 4, 'b')
Out [5]: 
[<matplotlib.lines.Line2D at 0x1e799158d10>,
 <matplotlib.lines.Line2D at 0x1e79a1b5810>,
 <matplotlib.lines.Line2D at 0x1e79a253750>]

So that's promising, but it's not rendering anything.

I'm also not using anaconda, just a normal python 3.11 environment. Still looking into this.

AdamYoblick avatar May 12 '25 20:05 AdamYoblick

I also tried running these commands from a console. I opened a command prompt in my python 3.11 environment, then typed ipython to get the interactive prompts. I entered all the commands listed and didn't see any graph either. I searched online and one answer said we need to call the show() function.

So I tried calling plt.show() and it worked:

Image

I'm not sure if this is the correct solution here, or if the tutorial is out of date, or if something changed on our end.

Also, calling plt.show() from the prompt within Visual Studio did nothing.

AdamYoblick avatar May 12 '25 21:05 AdamYoblick

For me it works only with the provided Python 3.9 but anything else, simply typing 2+2 hangs

ghost avatar May 20 '25 23:05 ghost