IdeaVim with Jupyter Notebook on PyCharm - python

I am trying out IntelliJ. I have installed the Python plugin, and IdeaVim.
I cannot navigate properly across Jupyter Notebook cells using hj. I mean, on normal mode, I cannot go to the next (or previous) cell, even if there is one, using hj.
Is there a way to do it without the mouse, possibly rebindable? I have read the tutorial and tried to find something in the program, but could not.

Ideavim plugin doesn't seem to support Pycharm's notebook implementation as of right now :(
There's an open issue marked as "bug" on Ideavim's issue tracker that was opened back in 2015 and it seems like it doesn't have any progress made since.
However according to the comment in the issue thread you can:
funny way to get into the command mode is type something so that the suggestion panel appears, now press "esc" you will get into Vim command mode
So this might indicate that this could be solved and updated in the future.
As an alternative you can try out jupyter-vim-binding, however it doesn't work with Pycharm either.

Related

Jupyter Notebook debugging not working on VS Code

I'm trying to activate the debugging functions that are now available on VSCode for Jupyter Notebooks but I'm having some problems with that.
In my interface I can see the button to 'Run by Line' next to every cell but when I click it nothing happens except the normal execution of the entire cell, but that mode is supposed to execute your cell line by line... I've tried putting some breakpoints even I know it is not necessary in that mode but still nothing.
As you can see here the buttons for debugging are shown a few seconds after hitting the 'Run by Line' button but they do nothing.
As a workaround to not being able to use that useful mode, I tried the standard debug mode of VSCode for Jupyter Notebooks which let you go breakpoint to breakpoint on your cell, the problem (I think it is) is that when I use that what VSCode does is open another tab with just the code of the cell I'm debugging in a temporary .py file, which is not the behaviour I would like to have, because I think it should do that on the Notebook tab itself without any new file...
Here I show you a screenshot of the temporary .py that it's created:
That's just the code of my notebook first cell!
Any help with this? I would like to solve both problems or at least one of them.
I've checked the requisites for the debug modes and make sure I fullfill everyone of them but I'm not so used to use the debug functionalities of VSCode so maybe I'm skipping something.
This is a current bug. It was notified to the dev team here:
https://github.com/microsoft/vscode-jupyter/issues/8258
The bug is caused by vscode using a shortened username. In my case GUILLE~1 instead of Guillermo.
The current solution available is to create a new user in your computer with a maximum length of 8 characters.

How to delete leftover commands in IPython console?

I recently opened Spyder after a really long time, and my IPython console immediately showed some leftover commands? Do they affect my next code, and if they do, how can I get rid of them? Screenshot
EDIT Solved: all i had to do is turn off symbolic mathematics in preferences/ipython console/advanced settings. When I turn it back on, it shows again. I would like to know is there any better solution for this?

VScode run code selection

I just made the transition from Spyder to VScode for my python endeavours. Is there a way to run individual lines of code? That's how I used to do my on-the-spot debugging, but I can't find an option for it in VScode and really don't want to keep setting and removing breakpoints.
Thanks.
If you highlight some code, you can right-click or run the command, Run Selection/Line in Python Terminal.
We are also planning on implementing Ctrl-Enter to do the same thing and looking at Ctr-Enter executing the current line.
You can:
open a terminal at Terminal>New Terminal
Highlight the code you want to run
Hit Terminal>Run Selected Text
As for R you can hit CTRL Enter to execute the highlighted code. For python there's apparently no default shortcut (see below), but I am quite sure you can add yours.
In my ver of VSCode (1.25), shift+enter will run selection. Note that you will want to have your integrated terminal running python.
One way you can do it is through the Integrated Terminal. Here is the guide to open/use it: https://code.visualstudio.com/docs/editor/integrated-terminal
After that, type python3 or python since it is depending on what version you are using. Then, copy and paste the fraction of code you want to run into the terminal. It now has the same functionality as the console in Spyder. Hope this helps.
I'm still trying to figure out how to make vscode do what I need (interactive python plots), but I can offer a more complete answer to the question at hand than what has been given so far:
1- Evaluate current selection in debug terminal is an option that is not enabled by default, so you may want to bind the 'editor.debug.action.selectionToRepl' action to whatever keyboard shortcut you choose (I'm using F9). As of today, there still appears to be no option to evaluate current line while debugging, only current selection.
2- Evaluate current line or selection in python terminal is enabled by default, but I'm on Windows where this isn't doing what I would expect - it evaluates in a new runtime, which does no good if you're trying to debug an existing runtime. So I can't say much about how useful this option is, or even if it is necessary since anytime you'd want to evaluate line-by-line, you'll be in debug mode anyway and sending to debug console as in 1 above. The Windows issue might have something to do with the settings.json entry
"terminal.integrated.inheritEnv": true,
not having an affect in Windows as of yet, per vscode documentation.

Python freezes when configuring IDLE

So, recently I was using the Python theme function for the IDLE program itself. I downloaded three themes and built my own one, which is selected now. The problem is, I forgot to set colours for the blinker and highlighting, which is hugely problematic. When I went to see if I could change back to the default setting, Python IDLE simply froze up when I selected 'Configure IDLE' under options. I can still scroll through the file, attempt to close the window and minimise it etc, but it has just frozen up. I can't close it or continue working with the file. I've removed Python and then reinstalled it but that hasn't worked, should I just manually delete the themes and force IDLE to use the original one, or is there a way to fix this?
I am running Python 2.7 on Windows 8.1.
Thanks
Turns out one way is manually deleting the faulty theme. This allows the Configure IDLE menu to open. Whoops.

How to get the ipython notebook title associated with the currently running ipython kernel

I usually have 5-10 different ipython notebooks running with associated consoles/kernels. It is hard for me to keep track of which console/kernel belongs to which notebook. For a while I put a comment with the notebook title at the top of each notebook and executed that comment in the kernel. That way I could type the '#' and then up arrow from console and it would show the comment. I think there is probably an easier way to keep track of my consoles.
The below code snippets show what is going on.
Suppose I am running an ipython notebook server, and I create a new notebook with a title called TestA.
Then suppose I run the following commands in the new notebook
%connect_info #prints connection information
%qtconsole
This opens up an ipython terminal console window (kernel might be the proper name) associated with the same notebook.
If I then type the following command in the ipython terminal console
%connect_info
I can determine which notebook is associated with which ipython consoles/kernels, but this requires a bit of work. Is there a command, magic, or macro that I can get the title (if present) of the currently running notebook?
I saw How do I get the current IPython Notebook name
Though the comments indicate this might not work, this solution appears to work on my setup but I wasn't sure if there is a better way to do this.
I decided to reask this question based on a Q&A on the SO meta site: https://meta.stackexchange.com/questions/147027/purposely-re-asking-duplicating-an-old-question
Answer has not changed, by design the kernel does not know what is speaking to it. Like TV news presenter do not have a camera pointed on every person that listen to TV at night.
And as usual the question is what are you trying to accomplish, you might be trying to do something the hard way.

Categories