UTide icon indicating copy to clipboard operation
UTide copied to clipboard

'Bunch' object has no attribute '__setstate__'

Open DSonDH opened this issue 1 year ago • 2 comments

I'm keep facing following error when I use VScode debugger. One funny thing is that after skipping this error a few times, my code runs well. And this error doesn't show up when I don't use VScode debugger.

Any ideas?

예외가 발생했습니다. AttributeError       (note: full exception trace is shown but execution is paused at: __getattr__)
'Bunch' object has no attribute '__setstate__'
  File "/home/sdh/HTY/src/utide/utilities.py", line 59, in __getattr__
    return self[name]
KeyError: '__setstate__'

The above exception was the direct cause of the following exception:

  File "/home/sdh/HTY/src/utide/utilities.py", line 61, in __getattr__ (Current frame)
    raise AttributeError(f"'Bunch' object has no attribute '{name}'") from err
  File "/home/sdh/miniconda3/envs/hty/lib/python3.9/site-packages/numpy/lib/format.py", line 800, in read_array
    array = pickle.load(fp, **pickle_kwargs)
  File "/home/sdh/miniconda3/envs/hty/lib/python3.9/site-packages/numpy/lib/npyio.py", line 256, in __getitem__
    return format.read_array(bytes,
  File "/home/sdh/HTY/src/utide/utilities.py", line 297, in loadbunch
    out[k] = _structured_to_bunch(xx[k], masked=masked)
  File "/home/sdh/HTY/src/utide/_ut_constants.py", line 11, in <module>
    ut_constants = loadbunch(_ut_constants_fname, masked=False)
  File "/home/sdh/HTY/src/utide/harmonics.py", line 8, in <module>
    from ._ut_constants import ut_constants
  File "/home/sdh/HTY/src/utide/_reconstruct.py", line 4, in <module>
    from .harmonics import ut_E
  File "/home/sdh/HTY/src/utide/__init__.py", line 3, in <module>
    from ._reconstruct import reconstruct
  File "/home/sdh/HTY/src/Step0-2_run_Utide.py", line 3, in <module>
    import utide
  File "/home/sdh/miniconda3/envs/hty/lib/python3.9/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/home/sdh/miniconda3/envs/hty/lib/python3.9/runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
AttributeError: 'Bunch' object has no attribute '__setstate__'

DSonDH avatar Oct 28 '24 09:10 DSonDH

The Bunch class used here does not support pickling and unpickling. I don't see why an attempt to unpickle a Bunch is occurring, however. Can you provide a minimal self-contained example showing this failure mode? I suspect it is related to your installation. I see that your numpy is coming from a miniconda environment, but your utide is not. How did you install it? Why isn't it installed in your conda environment?

efiring avatar Oct 28 '24 19:10 efiring

The Bunch class used here does not support pickling and unpickling. I don't see why an attempt to unpickle a Bunch is occurring, however. Can you provide a minimal self-contained example showing this failure mode? I suspect it is related to your installation. I see that your numpy is coming from a miniconda environment, but your utide is not. How did you install it? Why isn't it installed in your conda environment?

Hello, thanks for your comment. I'll check my installations. I updated the question that the error doesn't show up when I don't use VScode debugger.

DSonDH avatar Oct 29 '24 02:10 DSonDH