Jupyter notebook - drop down code - ipython

I am doing a Udemy course using Jupyter Notebook. On the tutorial the tutor gets drop down "help" after writing code. On my version this doesn't happen. Any idea how I can activate this feature?

Press the Shift and the Tab key at the same time when the cursor is inside the parenthesis.

Related

VSCode autocomplete/intellisense(?) in Jupyter Notebook when starting string literals keeps making me accidentally insert 'ArithmeticError' every time

screenshot of the popup code suggestion box being mentioned
In VSCode Jupyter Notebook code cells, I keep having this annoying popup when I open any single or double quotes. It doesn't appear on markdown cells, nor in regular editor on .py files. It doesn't look like your typical IntelliSense suggestions either (I think), and I've tried to disable as many of such extensions as possible, but I'm not able to get rid of this annoying popup.
Appreciate if someone could point me in the right direction. Or at least what it's actually called, so I can Google the correct term. Thanks.
Figured it out.
In VS Code settings, go to Extensions > Jupyter > Python Completion Trigger Characters
defaults were: .%'"
So I deleted the single and double quotes, restarted, and voila, no more annoying popups.

Notebook validation failed: Non-unique cell id 'hawaiian-pregnancy' detected. Corrected to '8fbbc816'.:

i have copied the notebook to create another version and all the time getting this strange errors, Does anyone have a clue how to get rid of it?
i have solved it with clicking "Trust" in jupyter notebook on the tool panel.
The best temporary solution so far is the following, from this GitHub issue:
First select all the cells in the Jupyter Notebook, then press the "cut/scissors" button (don't panic, at this point your Notebook will be empty), and finally press the "paste" button.

How to copy cells in Visual Studio Code when using Jupyter?

I'm working with a Jupyter notebook. How would you copy cells in Visual Studio Code? C to copy and V to Paste did not work for me as it would online.
Also, Visual Studio doesn't seem to offer right click options when working in the notebook. Is there a extension that would give me some options such as Cut, Copy, Paste, Delete Cell, Etc.?
I'm a developer on this extension, and I have a bit of a two part answer for you.
In the current (as of 2/16/21) stable release version of the extension notebook UI is done by a hosted webview, it was the only supported option at the time. As such it is lacking features both of Jupyter and of VS Code editor instances. It does not currently support cutting, copying and pasting of cells.
We are currently in the process of moving over to VS Code's new notebook UI that they provide. This allows better UI both for matching Jupyter and supporting more VS Code editor features. This current UI does allow for copying / cutting / pasting cells with the familiar Jupyter commands.
This support will not be added to the old editors, but currently the new UI is available if you use the extension with VS Code - Insiders and will soon start rolling out to VS Code Stable.
https://devblogs.microsoft.com/python/notebooks-are-getting-revamped/
Short answer: Supported with VS Code - Insiders now, and will be supported on stable VS Code in the future.
The new version of the visual studio Jupyter Notebook extension support all the standard operations for one or multiple cells of the jupyter notebook. For example, the following list shows some tested shutcuts:
To copy a selected cell(s) use: ctrl+c
To paste a selected cell(s) use: ctrl+v
To cut a selected cell(s) use: ctrl+x
To delete a selected cell(s) use: ctrl+x
etc.
Note that, as usual, to select multiples cells one should hold the ctrl button before selecting.
As of 2021-01-14, you can now select the cells, right click on any single one of the cells you selected (this will select them as a group if you select more than one) and have the option to press COPY. Or you can simply ctrl+C as a keyboard shortcut. The key here is when you copy and paste the cells to another notebook, your cursor needs to be outside any cells; that is you need to press somewhere outside the cell before pasting. In COLAB notebook, even if your cursor is on a cell, the copy and pasting method works. BUT here if you do that you will be pasting all of the codes inside the cell where your cursor is active; it will not paste the actual cells you copied.
Hope this wasn't too confusing.

How to Format Jupyter notebook in VSCode?

We can format python code in the jupyter notebook in the browser. After I change to VSCode and use the Microsoft extension, I find I can not format Jupyter notebook any more. Does anyone know how to solve this?
As Kyle Carow stated in their answer to Ian Huff: Formatting of notebooks is available by now.
MacOS: Option+Shift+F
Windows: Alt+Shift+F
Pressing these keys will either trigger a formatting of the active cell or the notebook as a whole if no cell is active.
Windows: Shift+Alt+F
Is what worked for me with Black formatter set up on VS Code Version: 1.64.2
Or right click "Format Notebook" to format entire notebook.
Format Notebook
I do not think VS Code support formatting of code cells, but if you use the black code formatter, then you can use the blackcellmagic %%black to format the code in a cell.
You need to have pip install black and blackcellmagic, details here: https://github.com/csurfer/blackcellmagic
I'm not exactly sure what is being asked here. But currently in VS Code the notebook editor and interactive window do not support formatting python code.
However we are moving to a new UI for those features which will support all the formatting features of VS Code in .py files. If you try out VS Code - Insiders now you should see this support and can try it out. This new UI will eventually be rolling out to VS Code stable.
Edit: The new UI which supports formatting in cells is now out by default for stable users.
If you have a Jupyter notebook open in VS Code with the Jupyter notebook extension, it should be possible to format code cells with Ctrl+ Shift+ I.
I'm not sure if this shortcut differs between operating systems, you can check what the shortcut is yourself by hitting Ctrl+ Shift+ P and then searching for "Format cell". The shortcut should be displayed then.

Jupyter Notebook alt+D shortcut collision

I wanted to try out Jupyter notebooks, but quickly ran into problems with it since my keyboard layout uses alt+d and alt+f to insert ( and ) which doesn't work. All my other modifiers are also based on alt+{letter} and they all work, but for some reason alt+d and alt+f are getting swallowed by something. However I can't find any shortcut documented for those two combinations either.
I've added the following to ~/.ipython/profile_default/static/custom/custom.js
$([IPython.events]).on("app_initialized.NotebookApp", function () {
// No idea what these do, but the mess with my keyboard layout
IPython.keyboard_manager.command_shortcuts.remove_shortcut("Alt-d");
IPython.keyboard_manager.command_shortcuts.remove_shortcut("Alt-f");
});
But this doesn't seem to have any effect even after a server restart and browser reload.
Thanks
So after some amount of digging I figured out what causes this. The problem is not in the jupyter notebook, but is caused by a shortcut in the underlying CodeMirror editor. As seen here CodeMirror adds shortcuts for Alt +d and Alt + e. The way to disable these is putting the following in ~/.jupyter/custom/custom.js
delete CodeMirror.keyMap.emacsy["Alt-F"];
delete CodeMirror.keyMap.emacsy["Alt-D"];