'An Issue with Importing Files with Pickle

I have saved multiple figures by using pickle.dump on a computer device. Now, I want to load the files on my laptop using pickle.load. I wrote the following code for filename in filenames:

    with open( path + filename + '.pkl','rb' ) as file:
              linedata = pickle.load(file)
    # plt.close()
    ax = plt.gca()
    
    for m in range( len(M) ):
        line = ax.lines[ m ]
        keyname = filename + '_M=' +  str( M[m] )
        outdict[keyname] = [ line.get_xdata(line), line.get_ydata(line), Linestyle[cnt], Labels[cnt]+ r'$~M={}$'.format(M[m]), Colors[m] ]
        plt.close()
    cnt+=1

However, the following error is raised:

AttributeError: Can't get attribute '_picklable_subplot_class_constructor' on <module 'matplotlib.axes._subplots' from '/Users/saleh/miniforge3/lib/python3.9/site-packages/matplotlib/axes/_subplots.py'>

I would appreciate if anyone can solve my problem.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source