haochengxia / vscode-pydata-viewer

Display PyData files (.npz .npy .pkl .pth) in VSCode.
https://marketplace.visualstudio.com/items?itemName=Percy.vscode-pydata-viewer
MIT License
14 stars 8 forks source link

__init__() got an unexpected keyword argument 'callbacks' #18

Closed beijiguang94 closed 7 months ago

beijiguang94 commented 7 months ago

When I open a .pickle file, it only shows one line of error as the title above.

haochengxia commented 7 months ago

Thank you for contacting us. Can you please provide me with the file causing the error or provide steps to reproduce it?

beijiguang94 commented 7 months ago

The .pickle file is just a normal figure generated using the following code in a vscode terminal: import pickle import matplotlib.pyplot as plt

fig1 = plt.figure() plt.plot([1,2], [1,2]) pickle.dump(fig1, open('test.pickle', 'wb'))

Then the file test.pickle can be loaded and the original figure can be shown again using code: fig2 = pickle.load(open('test.pickle', 'rb')) plt.show()

But clicking on the file test.pickle gives an error as in the title with the extension installed.

haochengxia commented 7 months ago

Thank you for bringing this to our attention. We are pleased to inform you that starting from version 0.0.12, we now offer support for displaying plt figures. Your feedback is highly appreciated.

For the example you mentioned: image

beijiguang94 commented 7 months ago

Thanks. But it still reported the same error even if I had updated the version to 0.0.12. FYI, I use vscode + WSL 2 on Windows.

haochengxia commented 7 months ago

Based on your problem, I believe there are two potential solutions to consider.

Cause: It appears that the version of matplotlib on the system where you attempted to load the pickled figure was older than the version used to create the pickle file.

Approach 1: Updating matplotlib should resolve the issue.

Approach 2: Perhaps you can try changing the extension setting to ensure consistency between the environment used to create the plt.figure instance and the one used to view the pickle file.

An illustration for modifying env for the extension: image

I hope this is helpful. Let me know if you need any further assistance with anything.

beijiguang94 commented 7 months ago

Yes, approach 2 works. Thanks for pointing it out.