Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error using Anaconda Python 3.6 in pickle #4

Open
monajalal opened this issue Mar 8, 2018 · 0 comments
Open

Error using Anaconda Python 3.6 in pickle #4

monajalal opened this issue Mar 8, 2018 · 0 comments

Comments

@monajalal
Copy link

So here:

    glove_path = './embeddings/glove_{}_{}.pkl'.format(dataset,mode)
    if(os.path.isfile(glove_path)):
            print("Reusing glove dictionary to save time")
            #with open(glove_path,'r') as f:
            with open(glove_path, 'rb') as f: #python 3 for pickle byte size object is needed not str
                    glove = pickle.load(f)
            save = False

If I try

with open(glove_path,'r') as f:

I get the following error:

    Reusing glove dictionary to save time
    Traceback (most recent call last):
      File "prepare.py", line 315, in <module>
        glove = pickle.load(f)
    TypeError: a bytes-like object is required, not 'str'

and if I try

with open(glove_path, 'rb') as f: #python 3 for pickle byte size object is needed not str

I get the following error:

Reusing glove dictionary to save time
Traceback (most recent call last):
  File "prepare.py", line 315, in <module>
    glove = pickle.load(f)
EOFError: Ran out of input

Can you please guide how to fix this?

I have imported pickle like

import six; from six.moves import cPickle as pickle #import compatability with Python 2 using six
while it was originally imported as:

import cPickle as pickle #python 2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant