vscodeJupyter icon indicating copy to clipboard operation
vscodeJupyter copied to clipboard

feature request: support IPython console

Open DonJayamanne opened this issue 7 years ago • 32 comments

From @mickeydonkey on November 3, 2016 2:6

Dear developer of pythonVSCode:

IMHO current IPython integration #303 is like a variation of jupyter notebook. While IPython console is a popular REPL mode which arms user with convenient magic commands. To enter IPython console, one just types 'ipython' in terminal. It'll be great to see functionality like:

  1. simply "python: run selection in ipython console"
  2. running a code cell in the IPython console and display its output in parallel;

Thanks

Copied from original issue: DonJayamanne/pythonVSCode#480

DonJayamanne avatar Mar 09 '17 14:03 DonJayamanne

From @mickeydonkey on November 3, 2016 5:7

IPython Qtconsole is more powerful than plain IPython console in terminal. An app that embeds IPython QTconsole is spyder-ide, I'm not sure If it can be embeded in vscode though.

DonJayamanne avatar Mar 09 '17 14:03 DonJayamanne

@mickeydonkey Embedding the QTconsole into VS Code wouldn't be possible. However we could build something similar. But the question is, how many people would want such a feature in VS Code? Up votes to this issue will tell us.

DonJayamanne avatar Mar 09 '17 14:03 DonJayamanne

From @gandhis1 on November 3, 2016 21:9

@mickeydonkey , What benefit do you see in using IPython console instead of the Jupyter notebook kernel? To me, having both features is redundant. You can run magic commands in Jupyter, and you can also run selections in Jupyter.

DonJayamanne avatar Mar 09 '17 14:03 DonJayamanne

From @mickeydonkey on November 5, 2016 6:36

@gandhis1 Thanks for your interest. Yes, IPython console, IPython QTconsole and Jupyter notebook all provide some functionalities in common, like the magic commands you mentioned. that is because of the IPython kernel they are all connected to. IPython console or the improved counterpart - IPython QTconsole- is not the reinvented wheel compared to jupyter notebook.

To me IPython console is more like the under-the-hood mode of IPython kernel, all user codes history in the IPython kernel are recorded and displayed in the console so I can see the order in which my code inputs were ran. By pressing upper-arrow key I can easily call the code in history and make some modification based on that. But when it comes notebook, code cell are overwritten when I modify existing code cells and the order of cells are not that easy to figure out. That is especially true when your task involves lots of small try-and-error experiments before you finally know how to do the job correctly. I am more comfortable with shell-like convenience, In fact Most of time Qtconsole's image-display feature can make me happy and I only resort to notebook when I need fancier data visualization functionality for data-presentation purpose.

IPython console can also be used as a debug console as the PyCharm IDE already supported. When the program stops at one breakpoint, I can explore with IPython console's functionality. For debugging data science programs like data wrangling, Traditional watch list approach is not good for watching data tables, It could be a huge benefit if we can display some inline image to inspect the on-the-fly status of our "tables". Actually a friend of mine who comes from MATLAB world have complained to me the lack of similar feature in Python world.

Finally, I've tried several IDEs and found out no perfect one for data science project. Either weak in debug, visualization or interactivity. As VS Code use the web-technology like RStudio, more possibilities are open. I am looking forward to seeing VS Code growing into the de facto data science IDE for python. BTW, another promising one is Atom except it's sluggish.

DonJayamanne avatar Mar 09 '17 14:03 DonJayamanne

From @martinfiers on November 12, 2016 14:55

I would also like to vote for this feature. My main usage would be to run small try-and-error experiments without having to leave the editor environment. Secondly, I'd use it to run small pieces from selection or from a code cell; inspect the results, experiment with some list comprehensions based on the available variables, etc, in a REPL fashion. So quite similar to what @mickeydonkey explains.

Resetting the console would be quite important, especially when the applications you're debugging are very stateful.

DonJayamanne avatar Mar 09 '17 14:03 DonJayamanne

From @Twizzledrizzle on December 4, 2016 9:30

Also interested in this! Currently testing with running ipython in the debug console instead

DonJayamanne avatar Mar 09 '17 14:03 DonJayamanne

From @gandhis1 on December 9, 2016 22:18

I have a few additional thoughts on this. There are currently a couple of actions that can be performed in the editor, "Run Python File in Terminal" and "Run Selection in Python Terminal". What if a setting was added which allows one to use iPython Console instead of a regular Python Terminal, and then executing code in the terminal operated off of this?

DonJayamanne avatar Mar 09 '17 14:03 DonJayamanne

From @jruizaranguren on December 29, 2016 17:32

This can be done just by changing the pythonpath setting in the workspace settings (or alternatively in the user settings). For instance, if you have installed Anaconda:

{
    "python.pythonPath": "D:/Anaconda/Scripts/ipython3.exe"
}

DonJayamanne avatar Mar 09 '17 14:03 DonJayamanne

From @gandhis1 on January 3, 2017 15:57

If I am running an application stand-alone, of course I want to use the regular Python interpreter, which is more lightweight and has faster startup time. Only if I want to be doing interactive stuff do I want to be using IPython. To use the same for both would not be ideal.

DonJayamanne avatar Mar 09 '17 14:03 DonJayamanne

+1 this is a must. I completely agree with @mickeydonkey

bordingj avatar Jun 28 '17 05:06 bordingj

I also would love to have that feature! I think a lot of people working on data science related topics are having the same workflow described by @mickeydonkey

KaiLicht avatar Aug 09 '17 09:08 KaiLicht

I very much like the REPL style development with IPython console. The best part is auto-complete of live variables. It would be great to get support for this, pretty much as how @mickeydonkey described. Thanks!

madcowswe avatar Oct 07 '17 09:10 madcowswe

+1 for the reasons described above.

somelinguist avatar Dec 06 '17 13:12 somelinguist

+1 Before using VS Code, I always had Notepad++ and Jupyter QTConsole on either side of my screen to do the REPL work space. Having them in the same program and even have some better interactivity would be fantastic.

jrwrigh avatar Dec 24 '17 21:12 jrwrigh

+1 This feature probably is the last thing that prevents me from migrating completely to VScode.

chenwang avatar Jan 05 '18 22:01 chenwang

+1 for the reasons of debug.

Louis-udm avatar Jan 25 '18 16:01 Louis-udm

Me too. Main reason that's preventing me from changing from Spyder + GitHub Desktop to VS Code.

yehoshuadimarsky avatar Jan 29 '18 18:01 yehoshuadimarsky

+1 for the debugging capabilities!

ftpronk avatar Feb 01 '18 18:02 ftpronk

@ftpronk @yehoshuadimarsky @Louis-udm @chenwang @u2berggeist @somelinguist @caesar, @surelyourejoking, @yehoshuadimarsky, @shelper, @nunobbras, @johnnadratowski, @Louis-udm @benjello @nunobbras, @rathsandeep, @wdscxsj, @johnnadratowski, @u2berggeist, @Louis-udm, @benjello @vograno, @pabloazurduy, @riccardo-gallini, @rathsandeep, and @ftpronk

Please could you vote 👍 (if you haven't) on the top comment (https://github.com/DonJayamanne/vscodeJupyter/issues/19#issue-213049637), this way its easier to capture the total number of votes on this issue. Thanks

DonJayamanne avatar Feb 01 '18 18:02 DonJayamanne

Really want this

troflog avatar Feb 05 '18 17:02 troflog

@troflog Please 👍 on the very first comment so we can keep track of total votes on this issue.

DonJayamanne avatar Feb 05 '18 17:02 DonJayamanne

@DonJayamanne The accumualted 👍s of this issue reveals abundant demand, In hope of official support from Microsoft, I post an feature request on (https://github.com/Microsoft/vscode-python/issues/727) .

taoluo avatar Feb 08 '18 04:02 taoluo

@DonJayamanne sorry, I got a bit lost in this thread and want to know if you managed to set ipython as the debug console in VS Code in the end or if this is still a desired feature? I tried to add the below to my config file but got no luck:

        {
            "name": "ipython",
            "type": "python",
            "request": "launch",
            "program": "${file}",
            "pythonPath": "/Users/tsando/anaconda3/bin/ipython"
        }   

What this does is that it launches the the program from the integrated terminal using ipython,

screen shot 2018-04-05 at 14 53 35

but the debug console is still not ipython clearly, as when I try to look at the head of a pandas dataframe, it gives the output in the wrong way - see screenshot below

screen shot 2018-04-05 at 14 53 04

Do you have any ideas or managed to figure how to get ipython in the debug console? Thanks!

tsando avatar Apr 05 '18 13:04 tsando

I created a small extension to add this feature, while we wait for an official implementation from Microsoft. https://marketplace.visualstudio.com/items?itemName=pancho111203.vscode-ipython

It basically adds two commands:

  • ipython.sendFileContentsToIPython - send whole file to ipython
  • ipython.sendSelectedToIPython - send selected lines (or current)

If you find any issues with it, please post them here: https://github.com/pancho111203/vscode-ipython/issues

franciscorubin avatar Apr 19 '18 11:04 franciscorubin

@pancho111203 thanks, but does this extension work also in debug mode? i.e. when i debug, is the debug console an ipython console? thanks.

tsando avatar Apr 19 '18 14:04 tsando

@tsando No, it doesn't. I could add the ability to use breakpoints but I don't see the point. In my opinion the debugger vscode provides works perfectly for that use case.

franciscorubin avatar Apr 20 '18 07:04 franciscorubin

@pancho111203 but i thought the point of this thread was to address that... i don't think the VS Code debugger is very friendly visually when it comes to debug python as PyCharm is. For example, when examining pandas dataframes, e.g. df.head(), the VS Code debugger shows a nasty print style, with no line breaks as follows:

screen shot 2018-04-20 at 10 27 49

whereas in Pycharm debug mode, it uses the ipython console, so you can see the df nicely, and also use the tab autocomplete functionality of ipython, as well as all the magic functions, and plotting. This is how it looks in PyCharm:

screen shot 2018-04-20 at 10 32 20

tsando avatar Apr 20 '18 09:04 tsando

Upvoted. I also believe that IPython console is an essential component of a Python IDE.

htcai avatar Apr 21 '18 15:04 htcai

Upvoted. Having the code editor and the ipython console side by side (horizontally) is very useful for scientific computing, and is in fact what Spyder has been using. (Having just a plain Python console isn't quite enough because we often need to do quick visualizations in the console.)

jsh9 avatar Jul 20 '18 06:07 jsh9

I totally agree when doing any type of scientific computing there are two additions needed ipython console and variable explorer this would boost the use of vs code python significantly

boazdori avatar Aug 15 '18 09:08 boazdori