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

A solution for **pickle.load()** #36

Open
doujiang-zheng opened this issue Jul 10, 2019 · 0 comments
Open

A solution for **pickle.load()** #36

doujiang-zheng opened this issue Jul 10, 2019 · 0 comments

Comments

@doujiang-zheng
Copy link

  • I use anaconda3 as my base python environment. However, the error that _pickle.UnpicklingError: the STRING opcode argument must be quoted always came out whenever I tried with python3 + open('adj_mx.pkl', 'rb') or python3 + open('adj_mx.pkl', 'r') in the interative shell.
  • Then I tried with python2 + open('adj_mx.pkl', 'rb'), and it came out with the error raise ValueError, "insecure string pickle".
  • Finally, it worked with python2 + open('adj_mx.pkl', 'r'). However, it is inconsistent with code gen_adj_mx.py, and utils.load_pickle. It confused me for quite a few days.

Solution

Python 2.7.15
>>> import numpy as np
>>> import pickle
>>> f = open('adj_mx.pkl', 'r')
>>> data  = pickle.load(f)
>>> with open('adj_mx_new.pkl', 'wb') as f:
>>>    pickle.dump(data, f, protocol=2)

You can replace the newly generated adj_mx_new.pkl with adj_mx.pkl. Then, it works python run_demo.py --config_filename=data/model/pretrained/METR-LA/config.yaml both under Python2 and Python3.

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