One of the disadvantages of Jupyter / iPython over Pycharm or Spyder is that I cannot see the documentation of the present code fragment / class / command by default (i.e.: that the referring docstring / signature is not shown automatically).
Is there any plugin / workaround possible to achieve this in a Jupyter notebook as well?
Execute a method with ? and the bottom pane will show up.
Inside the parenthesis of a method use shift + tab to bring up documentation pop-up.
Related
I'm working on a Python project using VSCode and Jupyter notebooks.
When working in a notebook, I can bring up the docstring for a given method by pressing shift+tab.
This previews the same text as doing print(method_name.__doc__), see screenshot below.
The above provides a clear picture of which arguments the method expects and what it returns, which is helpful to me.
I want to do the same thing in VSCode.
Looking at the answers to this SO question, there's a few hotkeys to view documentation (ctrl+k ctrl i, ctrl+space).
However, these do not display the same docstring, but something near-incomprehensible and not very helpful to me - see screenshot below.
What can I do to quickly preview that docstring in VSCode?
I want to be able to autohide code cells after they have run once in a jupyter notebook.
I am calling a function that prints some output. For example
print("Hello World")
The problem I am trying to solve is that after the output is printed, the code block stays there. I can use ctrl k + ctrl o to hide the code block after execution however there are many code blocks like that and I want it to be automatic. I tried using some javascript (https://habr.com/en/post/439570/) however that didn't work as expected. I am aware that I can use NBconvert to hide all the code cells while generating a pdf however I want only some cells to be hidden and that to in the raw notebook.
I looked into how we can add metadata in the cell to hide it with python here: https://jupyterbook.org/content/metadata.html
However, I want to do it locally on some cells, and I want to prevent file changed, do you want to overwrite your notebook prompts.
Is this possible?
For Vscode, refer to the official documentation https://code.visualstudio.com/docs/datascience/jupyter-notebooks, however I couldn't find anything related to autohide/collapse when using Vscode. They might release this functionality in their next release.
When I use browser to open Jupyter notebooks, I can use Shift + Tab shortcut to get a python function doc string; however, in VSCode, that shortcut does not work. Does anyone know which shortcut gives me the docstring there?
I found this but cannot understand the suggested solution (what is Ctrl + K Ctrl + I ?)
shows the keyboard shortcuts that have been set up and help below it will show you how to change what you want to change
When using VSCode in Windows, the default shortcut key for displaying the python function docstring is "ctrl+k ctrl+i". When using it, please place the mouse on the area of the python module or method that needs to be viewed (front or middle or back All works):
In addition, please check whether other shortcut keys of "editor.action.showHover" have been set in "keybindings.json".
Reference: Keybindings in VSCode.
I am working on MacOS v10.14.6 and using the Python interactive window of VScode v1.38.1.
I write code in a .py file and use #%% to create cells and shift+enter to run them in the interactive window.
Today the layout of the interactive window changed, but I didn't do any update and I did not change my settings.
It now shows icons on the top left (as on the screenshot below) instead of showing them on the top right, as it was the case before (as shown in the tutorial).
To me it looks like that doing shifts+enter now launchs a jupyter notebook similar to the one now supported by vscode, because the icons are similar. See the ones on this tutorial here.
The really annoying thing is that now my plots have a dark background, instead of a white one as it was the case before.
I checked and the option python.dataScience.ignoreVscodeTheme is still set on True.
Do you have an idea what happened ?
Thanks for the info Louis. So you are still seeing the interactive window there, not the new notebook experience, we just made some tweaks to the icons and icon locations to match the interactive window up better with the new experience. However while much of that is expected we did break the ignoreVscodeTheme setting. We have an issue filed on that there and it's on our immediate list to fix. Sorry about that, and thanks for reporting.
https://github.com/microsoft/vscode-python/issues/7847
When I create a notebook with plotly plots, save and reopen the notebook, the plots fail to render upon reopening - there are just blank blocks where the plots should be. Is this expected behavior? If not, is there a known fix?
Check to make sure your notebook is marked as "trusted", either in the top-right corner of the notebook, or in the File menu.
My notebooks are trusted by default, but I managed to reproduce your observed behaviour by temporarily removing my ~/Library/Jupyter/nbsignatures.db file, which forces Jupyter to run the notebook as untrusted. Clicking the tile in the top-right corner to trust the notebook fixed the issue for me.
This page in the jupyter docs, Security in notebook documents explains further:
The security problem we need to solve is that no code should execute just because a user has opened a notebook that they did not write. Like any other program, once a user decides to execute code in a notebook, it is considered trusted, and should be allowed to do anything.
I also meet this annoying issue. I find no way to reveal them on the notebook, but I find a compromise way to display them on an html page that is File -> Print Preview.
The reason as documented here:
Note: Default renderers persist for the duration of a single session,
but they do not persist across sessions. If you are working in an
IPython kernel, this means that default renderers will persist for the
life of the kernel, but they will not persist across kernel restarts.
As indicated in the troubleshooting documentation, "JupyterLab Problems" section, You have two options to solve the problem:
calling fig.show("notebook") instead of just fig.show().
If this problem is recurrent, you can use this:
import plotly.io as pio
pio.renderers.default='notebook'
Credits for here