Is there a way to un-import a package from Jupyter Notebook without restarting the kernel?
Why I Ask: I have a model that takes a long time to train. I am plotting some of the output of this model and when I imported seaborn it caused problems with the some of my plots. I would like to un-import seaborn without restarting the kernel and retraining the model.
I know there are workarounds like pickling the model and then replotting, but this situation got me curious about un-importing a package in Jupyter. Is that possible at all?
2 Answers 2
I assume you want to restore the defaults of the rcParameters of matplotlib, rather than unimport another module. Even if you could unimport it, the plotting parameters would remain changed.
plt.rcdefaults()
 1 Comment
When using seaborn version 0.8, it should not interfere with your plots.
When using seaborn version 0.7 or below, you may import seaborn.apionly instead of import seaborn for the same effect. If you already have imported seaborn see @philippd's answer.
Comments
Explore related questions
See similar questions with these tags.