question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unable to load .spydata files containing numpy object arrays

See original GitHub issue

Issue Report Checklist

  • Searched the issues page for similar reports: https://github.com/spyder-ide/spyder/issues/10013 - same issue, but no followup

  • Read the relevant sections of the Spyder Troubleshooting Guide and followed its advice

  • Reproduced the issue after updating with conda update spyder (or pip, if not using Anaconda)

  • [X ] Could not reproduce inside jupyter qtconsole (if console-related) (not applicable?)

  • Tried basic troubleshooting (if a bug/error)

    • Restarted Spyder
    • Reset preferences with spyder --reset
    • Reinstalled the latest version of Anaconda
    • [X ] Tried the other applicable steps from the Troubleshooting Guide
  • [X ] Completed the Problem Description, Steps to Reproduce and Version sections below

Problem Description

When attempting to load .spydata files that contain numpy object arrays, i get the following error:

image

I believe the issue is in iofuncs.load_dictionary() https://github.com/spyder-ide/spyder/blob/9b3e311c3289adeb104d7b60c013e8b34d43b091/external-deps/spyder-kernels/spyder_kernels/utils/iofuncs.py#L415

This stack exchange post provides workaround by modifying the default for np.load() to allow_pickle=True

I’m not sure if this is legitimately a bug or, perhaps a security feature, as per this warning in the numpy documentation here

image

What steps reproduce the problem?

  1. Create a numpy array with dtype=‘object’, for example image
  2. Save environment as foo.spydata using ‘Save Data’ button above Variable Explorer Pane
  3. Restart spyder and attempt to load foo.spydata using ‘Import Data’ button above Variable Explorer Pane

What is the expected output? What do you see instead?

Expected out put is that the ‘objArray’ variable is imported. Instead, error above occurs “Object arrays cannot be loaded when allow_pickle=False”

Versions

  • Spyder version: 4.0.1
  • Python version: 3.7.3 (64-bit)
  • Qt version: 5.9.6
  • PyQt version: 5.9.2
  • Operating System name/version: Windows 10

Dependencies

atomicwrites >=1.2.0         :  1.3.0 (OK)
chardet >=2.0.0              :  3.0.4 (OK)
cloudpickle >=0.5.0          :  1.3.0 (OK)
diff_match_patch >=20181111  :  20181111 (OK)
intervaltree                 :  None (OK)
IPython >=4.0                :  7.12.0 (OK)
jedi =0.14.1                 :  0.14.1 (OK)
nbconvert >=4.0              :  5.6.1 (OK)
numpydoc >=0.6.0             :  0.9.2 (OK)
pexpect >=4.4.0              :  4.8.0 (OK)
pickleshare >=0.4            :  0.7.5 (OK)
psutil >=0.3                 :  5.6.7 (OK)
pygments >=2.0               :  2.5.2 (OK)
pylint >=0.25                :  2.4.4 (OK)
pyls >=0.31.2;<0.32.0        :  0.31.7 (OK)
zmq >=17                     :  18.1.1 (OK)
qdarkstyle >=2.7             :  2.8 (OK)
qtawesome >=0.5.7            :  0.6.1 (OK)
qtconsole >=4.6.0            :  4.6.0 (OK)
qtpy >=1.5.0                 :  1.9.0 (OK)
rtree >=0.8.3                :  0.9.3 (OK)
sphinx >=0.6.6               :  2.4.0 (OK)
spyder_kernels >=1.8.1;<2.0.0:  1.8.1 (OK)
watchdog                     :  None (OK)
cython >=0.21                :  0.29.15 (OK)
matplotlib >=2.0.0           :  3.1.3 (OK)
numpy >=1.7                  :  1.18.1 (OK)
pandas >=0.13.1              :  1.0.1 (OK)
scipy >=0.17.0               :  1.4.1 (OK)
sympy >=0.7.3                :  1.5.1 (OK)

Issue Analytics

  • State:open
  • Created 4 years ago
  • Comments:12 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
moreza14commented, Nov 23, 2022

Hi, I had this problem and the way I got around it was to convert the numpy array with dtype = 'object' to a list (using np.tolist() ) and then save the environment using spyder’s interface.
After using this method spyder loads the .spydata with no errors. ( I haven’t changed the allow_pickle at all)

In my case, I have used dtype='object' to either store something other than a float ( a decimal number ) or a ragged nested sequence. so saving it as a list might be a better option anyways.

1reaction
martinclaussecommented, Oct 19, 2022

This issue isn’t resolved for Spyder version 5.3.2 and 1.23.3.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Unable to open .spydata in spyder: 'Object arrays cannot be ...
spydata file with less objects (only two cells from the original script run). I tried opening the file in a new environment with...
Read more >
[Example code]-Load spydata file - appsloveworld.com
I'm coming from R + Rstudio. In RStudio, you can save objects to an .RData file using save() save(object_to_save, file ...
Read more >
Variable Explorer — Spyder 5 documentation
It shows the namespace contents (including all global objects, variables, ... NumPy arrays, Pandas DataFrames, Series and more; as well as being able...
Read more >
spyder-ide/public - Gitter
npy files for each numpy array present either at the top level or nested inside other saved objects. You can save and load...
Read more >
Command to Load .spydata file - Google Groups
Hi All, I'm pretty new to Spyder, having recently decided to migrate to it from MATLAB for my MSc research. I have a...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found