I have a jupyter notebook that creates a local cache of images. I would like to clear the cache before I run a particular cell. Does anyone know how to do that? I tried:
import gc
gc.collect()
But it had no effect. I also tried clear all the cookies and cache in chrome, but that did work either.
When you have Jupyter notebook opened, you can do this by selecting the Cell -> All Output -> Clear menu item.
Press 'control-shift-p', that opens the command palette. Then type 'clear cell output'. That will let you select the command to clear the output.
Jupyter Book can automatically run and cache any notebook pages. Notebooks can either be run each time the documentation is built, or cached locally so that notebooks will only be re-run when the code cells in a notebook have changed.
After the use of the cache, cache_clear() can be used for clearing or invalidating the cache. These methods have limitations as they are individualized, and the cache_clear() function must be typed out for each and every LRU Cache utilizing the function.
Try the following in a new cell of your Jupyter Notebook:
%reset -f
The above will clear all variables without User Confirmation
. If you want explicit user confirmation, just drop the -f
.
%reset_selective -f varName
The above will delete particular variable.
In case the Python version you are using is greater than 3.3, you may also try (I haven't used it!):
%store -d someVar # Remove particular variable and its value from storage
%store -z # Remove all variables from storage
For more info, check this doc.
I realise this isn't a great (bordering on terrible) answer - in short, close and re-open the browser.
I've been struggling with this myself today, and even clearing the browser cache did not seem to work. The only way I've found refresh images is to:
... I even tried deleting the referenced image file. But the browser still held onto it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With