Unable to pickle.load(fig) with mpl in jupyter notebook · Issue #8291 · matplotlib/matplotlib · GitHub
Skip to content

Unable to pickle.load(fig) with mpl in jupyter notebook #8291

Description

@cbyrohl

I use the following code snippet, similar to issue #3986 on Py35/matplotlib2.0.0 installed via Anaconda3:

import matplotlib.pyplot as plt
import numpy as np
import pickle



ax = plt.subplot(111)
x = np.linspace(0, 10)
y = np.exp(x)
plt.plot(x, y)
with open('bla.pickle', 'wb') as pickle_file:
    pickle.dump(ax, pickle_file)
import matplotlib.pyplot as plt
import pickle

with open('bla.pickle', 'rb') as pickle_file:
    ax = pickle.load(pickle_file)
plt.show()

The latter pickle.load() fails with:

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-23-0e84ab5169e3> in <module>()
     15 
     16 with open('bla.pickle', 'rb') as pickle_file:
---> 17     ax = pickle.load(pickle_file)
     18 plt.show()

/home/uni09/cosmo/cbyrohl/anaconda3/envs/py35/lib/python3.5/site-packages/matplotlib/figure.py in __setstate__(self, state)
   1443             allnums = plt.get_fignums()
   1444             num = max(allnums) + 1 if allnums else 1
-> 1445             mgr = plt._backend_mod.new_figure_manager_given_figure(num, self)
   1446 
   1447             # XXX The following is a copy and paste from pyplot. Consider

AttributeError: module 'ipykernel.pylab.backend_inline' has no attribute 'new_figure_manager_given_figure'

This code was executed in a jupyter notebook (ipython 5.3)..

When executing as usual python script, it works just fine. It also works fine when dumping in Jupyter and loading in script.

[TAC edited to add markup]

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions