What causes the error “_pickle.UnpicklingError: invalid load key, ' '.”?

前端 未结 5 2219
清歌不尽
清歌不尽 2020-12-08 13:49

I\'m trying to storage 5000 data elements on an array. This 5000 elements are storage on an existent file (therefore it\'s not empty).

But I\'m getting an error an

5条回答
  •  生来不讨喜
    2020-12-08 14:17

    I had a similar error but with different context when I uploaded a *.p file to Google Drive. I tried to use it later in a Google Colab session, and got this error:

        1 with open("/tmp/train.p", mode='rb') as training_data:
    ----> 2     train = pickle.load(training_data)
    UnpicklingError: invalid load key, '<'.
    

    I solved it by compressing the file, upload it and then unzip on the session. It looks like the pickle file is not saved correctly when you upload/download it so it gets corrupted.

提交回复
热议问题