我知道这个非常古老的问题Python酸洗错误:TypeError:对象pickle没有返回列表.问题与numpy?但唯一给出的答案是相当模糊的.
这是在Python 3.6中重现该问题的代码.
import pickle
from astroquery.irsa import Irsa
from astropy import units as u
# Query region.
table = Irsa.query_region("m31", catalog="fp_psc", spatial="Cone",
radius=.5 * u.arcmin)
# Dump table.
with open('table.pkl', 'wb') as f:
pickle.dump(table, f)
# This is where the issue appears.
with open('table.pkl', 'rb') as f:
table = pickle.load(f)
Run Code Online (Sandbox Code Playgroud)
尝试加载pickle数据时,它失败了:
Traceback (most recent call last):
File "/home/gabriel/Descargas/test.py", line 17, in <module>
table2 = pickle.load(f)
File "/home/gabriel/anaconda3/envs/cat-match/lib/python3.6/site-packages/astropy/table/column.py", line 238, in __setstate__
super_class.__setstate__(self, state)
File "/home/gabriel/anaconda3/envs/cat-match/lib/python3.6/site-packages/numpy/ma/core.py", line 5869, …Run Code Online (Sandbox Code Playgroud)