Cells unreadable/un-editable in Jupyter dashboards extension - python

I am having an issue in the jupyter dashboards extension:
https://jupyter-dashboards-layout.readthedocs.io/en/latest/getting-started.html#
When I move to grid view, all cells get stacked on top of each other making it impossible to read or even edit. Additionally, it will not let me switch back to notebook view without exiting and reopening the notebook.
This question seems like it has been asked:
Cell stacking on each other in Jupyter dashboard view
but I don't think it's actually been answered. Has anybody else come across this issue?

Related

Why does my JupyterLab cell turn orange with every new edit or when I type in it?

I recently installed Cron via jupyterlab_scheduler in the anaconda extensions in a conda environment I usually work in. This was to schedule my jupyterlab notebooks. However, there was a problem with the application and so I deleted it. Though it seems to have left some of its features like turning the cell orange and leaving an asterisk to the left of the cell number. The picture below demonstrates this:
I created a new environment though it seems to still be affecting it other environs. Is there any reason why this is still happening? Its a problem because previously, when I use to undo (ctrl + z), it used to undo everything in the cell and only the cell in question. But now it undoes everything across all cells. This is a problem for me as it changes the overall code I am working with.
Any idea how to rectify this?
As explained in the JupyterLab 3.1 changelog, specifically the user-facing changes section, a new new visual indicator was introduced to highlight cells in which the code changed in the editor since last execution:
The indicator is currently implemented by changing the cell collapser and the cell execution counter color to orange, and adding a filled orange circle icon left execution counter.
Hopefully, this will improve the situational awareness of the users and lead to more consistent state of the notebooks on save. If you come to like this solution you may be interested in using nbsafety which takes it a step further by actually analysing the dependencies and preventing out-of-order execution.
previously, when I use to undo (ctrl + z), it used to undo everything in the cell and only the cell in question. But now it undoes everything across all cells. This is a problem for me
Recently I've also experienced the same annoying problem. Here is a picture to illustrate how to disable "document-wide undo/redo".
JupyterLab -> Settings -> Advanced Settings Editor -> Notebook -> Ctrl-F to find "undo" -> check the box "Experimental settings to...".
After that remember to close and re-open JupyterLab...

Is there a way to autohide/autocollapse code cells after first execution in jupyter notebook?

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.

How to get ipywidgets interact to work in HTML?

I have a Jupyter notebook with the following cell:
from ipywidgets import widgets, interact
slider = widgets.IntSlider()
def print_val(v):
print(v)
interact(print_val,v=slider)
This works fine in the notebook - when I change the slider the printed output changes. But when I use nbconvert to convert the notebook into HTML, the slider still renders fine in the output HTML, but has no effect on the printed output.
Any idea how to get this to work? Maybe ipywidgets is not the right library for this kind of stuff?
Thanks!
I think you miss what nbconvert does. This utility is needed for converting notebooks to other formats, such as PDF, LATEX, etc. It is used for sharing and presentation. One loses the interactivity option once the notebook is converted.
The interactivity of the Jupyter notebook is provided by the Jupyter server that is started when you invoke jupyter notebook from command line.
So when you save notebook as a web page or convert it to HTML, you don't have the server back end part that processes all the changes. It is a static web page. Because the slider is a standard element it is rendered correctly, but nothing happens when you slide it: there is nothing "attached" to it to handle the events.
At the end, in order to be able to interact with Jupyter notebook, you need the some kind of Jupyter server to be running. It can be a local server if you need it only for yourself, or you can use Google Colab (or Jupyter Hub) if you want to collaborate with others.
Also, there are several solutions that allow one to have some interactivity on the graphs, like Bokeh and Plotly. They also require you to run some kind of server.
Of course, all that is relevant only if you need Python to process your data. If your needs are simple as showing the slider value you better off with a simple Javascript, that can handle the slider changes right in the browser, without the need to run any server at the back end.
An interesting option, although not a direct solution: voila.

What happened to the Python interactive window?

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

Plotly + iPython Notebook - Plots Disappear on Reopen

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

Categories

Resources