Jupyter Notebook Out of Memory Error! How to fix it? - jupyter-notebook

I was running and editing my jupyter notebook and it just stopped responding. The page does not even load and it says the error message "out of memory".
How can I fix it?
I already tried just removing the file I pulled from the data onto the notebook and it still does not even load the page.

Related

Table of Contents disappeared in Jupyter Notebook

Currently, a jupyter notebook does not show the lateral table of contents. All the other notebooks do.
In fact, for that notebook under menu->edit the nbextensions config disappeared, so, it looks like that notebook does not load the extension.
My jupyter version is 4.4.0.
How to fix that notebook?
I found the solution to this problem. All those advises like "close and then re-open", "clean output of the notebook" or "re-install extensions" won't work. The problem is in the javascript load timeouts.
In firefox press F12 and press on the red icon in the top right corner - you will see that you have an error
Load timeout for modules:
custom/custom,nbextensions/nbextensions_configurator/config_menu/main,
bla-bla-bla...
How to solve:
close the notebook in jupyter, open your ipynb file in any text editor, go to the end of it - you will find "metadata" section. Add the line
"setTimeout": 120
create a file ~/.jupyter/custom/custom.js if you don't have it (I have Linux, where it is in Windows - I have no idea, google for it) and put this contents into this file:
window.requirejs.config({
waitseconds: 90, // default is 30s
});
This page describes the problem in detail:
https://github.com/ipython-contrib/jupyter_contrib_nbextensions/issues/1195
In my case, disabling my ad-blocker brought the table of contents back.
Apparently, all it needs is to shutdown the notebook. After restarting it, all works fine. I suppose that problem happens when the notebook has been closed wrongly without the proper "close and halt" procedure.
My solution in these cases is, make a copy (File <Make a Copy), delete the original notebook and rename the copy (File <Rename)
For me it seems that one of the following steps worked:
Update all packages and jupyter notebook to the latest version using conda
Uninstall then install again the nbextensions configurator
Reboot the computer
For me the reason was 22 emojis in the headers, deleting 5 of them was enough for firefox to get toc back with no reloading and kernel operations.
I have the problem with Jupyter notebook version 6.1.4. After installing nbextensions and enabling extension "Table of Contents (2)" (as "toc" and "toc2" don't work), I cannot obtain the TOC of an a notebook (2.8 MB), while new notebooks have a table of contents.
Reloading, reopening, restarting jupyter does not help, even after a long wait (> 15 min).
I have tried with browsers Mozilla Firefox version 83 and Chromium version 87.
However, a workaround is to create a new notebook (with TOC), then copy all cells from old notebook to new notebook. In order to do this, this might be useful:
how to copy cells from notebook to notebook and
how to select all cells.
Actually I could not copy all cells at once, I had to do three partial copies.
Alas, my method is not only painful but also ineffective in the long term, as the TOC disappeared again.
Restarting the computer worked or did not work.
Opening a small notebook with a table of content and reloading the big notebook worked or did not work.
The problem concerns all Nbextensions, they are just not active for the big notebook. A Javascript console is shown in Google Chrome with Control Shift J.
Error: Load timeout for modules:
nbextensions/nbextensions_configurator/config_menu/main,nbextensions/init_cell/main,nbextensions/spellchecker/main,nbextensions/toc2/main,nbextensions/jupyter-js-widgets/extension

RStudio initialization error, unexpected exception, fatal error

I am having an issue starting RStudio (desktop) that I did not have before.
When I fire-up RStudio, within seconds, the grey screen freezes with the following error message:
RStudio Initialization Error
Unable to establish connection with R session
Once I click 'OK', I get the following two error messages:
RStudio
Unexpected exception: The complexity of the regular expression exceeded predefined bounds...
and...
R encountered a fatal error. The session was terminated.
Any help in resolving these errors is much appreciated.
The "unexpected exception" error reads as though something's going wrong with RStudio trying to run something it's loading automatically as it is starting up. So, the related question is: how can I start RStudio fresh without opening any of the previous files/code/data?
I have tried uninstalling and reinstalling both R and RStudio, and R is installed fine (I can open and work on the R console).
I am working with:
Mac OSX 10.10.5
R 3.3.3
RStudio 1.1.423
Thank you!
Just received word from the RStudio team and their solution worked for me.
Indeed, RStudio is crashing while attempting to open a file you had
opened from a previous session. You should be able to work around this
by resetting your RStudio state.
The instructions to reset RStudio are here. Relevant excerpts:
RStudio Desktop stores your custom settings and options in a hidden
directory called RStudio-Desktop. If this directory does not exist,
RStudio will create it on start up. This directory includes user
settings, log files, and other state information. Removing (or
renaming) this directory will reset RStudio's state analogous to a
fresh installation.
We recommend renaming this directory to create a backup version
instead of completely deleting it. This allows you to save your
settings, in case you want to revert back to them. Additionally, if
you experienced a crash or RStudio failed to start, this directory may
contain vital information for determining the source of the error. In
this case, we recommend renaming this directory to
backup-rstudio-desktop and sending it along if asked by RStudio
Support.
So, simply removing the ~/.rstudio-desktop file (actually, renaming it to ~/backup-rstudio-desktop so that I have a backup) just solved the start-up issue!
As a FYI to anybody who tried the solution above without success, I ended up updating/reinstalling the xfun package (install.packages("xfun")), which resolved this issue for me when resetting my RStudio state did not.

jupyter notebook takes forever to open and then pages unresponsive - [MathJax] issue

I'm trying to open a jupyter notebook and it takes a long time and I see at the bottom it's trying to load various [MathJax] extension, e.g. at the bottom left of the chrome browser it says:
Loading [MathJax]/extensions/safe.js
Eventually, the notebook loads, but it's frozen and then at the bottom left it keeps showing that it's trying to load other [MathJax] .js files.
Meanwhile, the "pages unresponsive do you want to kill them" pop up keeps popping up.
I have no equations or plots in my notebook so I can't understand what is going on. My notebook never did this before.
I googled this and some people said to delete the ipython checkpoints. Where would those be? I'm on Mac OS and using Anaconda.
conda install -c conda-forge nbstripout
nbstripout filename.ipynb. Make sure that there is no whitespace in the filename.
I had a feeling that the program in my Jupyter notebook was stuck trying to produce some output, so I restarted the kernel and cleared output and that seemed to do the trick!
If Jupyter crashes while opening the ipynb file, try "using nbstripout to clear output directly from the .ipynb file via command line"(bndwang). Install with pip install nbstripout
I was having the same problem with jupyter notebook. My recommendations to you are as follows:
First, check the size of the .ipynb file you are trying to open. Probably the file size is in MB and is large. One of the reasons for this might be the output of a dataset that you previously displayed all rows.
For example;
In order to check the dataset, sometimes I use pd.set_option('display.max_rows', None) instead of the .head() function. And so I view all the rows in the data set.
The large number of outputs increases the file size, making the notebook slower. Try to delete such outputs.
I think this will solve your problem.
Here restarting your kernel will not help. Instead use nbstripout to strip the output from command line.
Run this command -> nbstripout FILE.ipynb
Install nbstripout if it is not there
https://pypi.org/project/nbstripout/
It happened to me the time I decided to print a matrix for 100000 times. The notebook file became 150MB and Jupyter (in Chrome) was not able to open it: it said all the things you experienced and then the page died saying it was "OutOfMemory".
I solved the issue opening it in Visual Studio Code, there is a button "Clear All Output", then I saved the notebook again and it was back to some hundreds of KB, which I could open normally.
If you don't have Visual Studio Code installed, you can open the notebook with another editor (gedit if you use Linux or Notepad++ in Windows) and try to delete the output cells. This is more tricky since you have to pay a lot of attention in what you are deleting, otherwise the notebook will stop working.

Repair corrupted Jupyter notebook / load previous version?

I had a hardware crash while running a Jupyter notebook. After repairing the system and trying to restart the notebook, I got the following error message:
Error loading notebook
Unreadable Notebook: D:\Eddy\Documents\1604 Udacity\1612 Self-driving car Nanodegree\P4\P4 Eduard van Kleef.ipynb NotJSONError("Notebook does not appear to be JSON: ''...",)
Does anyone know of a way to revert to any of Jupyter's previous 'checkpoints'? Or of a way to at least partially restore a JSON?
If you are lucky then the ipynb file is corrupted but still there. In that case you can try opening it in a text file and copying the contents to a new notebook. But check the size of the file. If it is zero bytes, then there is nothing there!
This actually happened to me when my server ran out of memory and somehow the notebook got completely erased. Totally sucks.
Try this
jupyter nbconvert filename.ipynb --clear-output
It worked for me since it has corrupted because of Plotly behavior with some big data.
in your file directory that contains your ipynb file there is a folder called '.ipynb_checkpoints'. this folder does not show in the jupyter application so find it through windows explorer.
inside there's will be a file called urfilenamehere-checkpoint.ipynb
copy paste it to your file directory and open through the jupyter application it should probably work.
if your corrupted file is 0B, you definitely have to rely on the checkpoints.
do not create a new notebook with the same name it will overwrite the checkpoint.

Jupyter Notebooks Hang in Browser on Windows 10

I just installed Miniconda and the R Essentials bundle on my Windows 10 machine, following the instructions given here. Everything went swimmingly until I opened up an Anaconda command prompt and entered jupyter notebook and got an error. I then used ipython notebook which worked, so okay, no problem there.
However, after creating a new folder and trying to create a new R notebook within that folder, my Jupyter tabs started to hang. Whenever I try to do something, whether it is rename the notebook, run a block of code, basically anything, all of the Jupyter tabs sit there loading endlessly saying "Waiting for localhost..."
I try stopping the server and restarting it, but every time I try to do anything I get the same result. I also tried changing the port and running the command prompt as administrator--same result. I am using Chrome, which shouldn't be an issue.
Any ideas? I was really excited about using a Jupyter notebook to keep track of my analyses in R, but if I can't even get it to function out of the box I'll have to find a better solution.

Resources