a bytes-like object is required, not '_io.BufferedReader'

Viewed 11162

I'm trying to load the dumped files, using the following code:

cols = None
with open('./experiments/columns.p', 'rb') as p:
    cols = pkl.loads(p).read()

but i get this error instead:

"a bytes-like object is required, not '_io.BufferedReader' "

1 Answers

You're using pickle, so you should use the pickle.load function:

import pickle

with open('./experiments/columns.p', 'rb') as p:
    cols = pickle.load(p)

This is less likely to trigger a MemoryError.

Related