1

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?

asked Aug 31, 2017 at 21:03

2 Answers 2

3

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()
answered Aug 31, 2017 at 21:19
Sign up to request clarification or add additional context in comments.

1 Comment

Putting that right before my plt.show() fixed the issue. Thanks!
1

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.

answered Sep 1, 2017 at 8:19

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.