Python,如何处理“ValueError: unsupported pickle protocol: 4”错误?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/38466523/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Python, how to handle the "ValueError: unsupported pickle protocol: 4" error?
提问by DavideChicco.it
I'm new to Python. I've to run this TargetFinder script ("Custom Analyses").
我是 Python 的新手。我必须运行这个TargetFinder 脚本(“自定义分析”)。
I installed all the required python packages, and copied the code into a script I named main.py
, and ran it.
I got this error:
我安装了所有必需的 python 包,并将代码复制到我命名为 的脚本中main.py
,然后运行它。我收到此错误:
[davide@laptop]$ python main.py
Traceback (most recent call last):
File "main.py", line 8, in <module>
training_df = pd.read_hdf('./paper/targetfinder/K562/output-epw/training.h5', 'training').set_index(['enhancer_name', 'promoter_name'])
File "/usr/lib64/python2.7/site-packages/pandas/io/pytables.py", line 330, in read_hdf
return store.select(key, auto_close=auto_close, **kwargs)
File "/usr/lib64/python2.7/site-packages/pandas/io/pytables.py", line 680, in select
return it.get_result()
File "/usr/lib64/python2.7/site-packages/pandas/io/pytables.py", line 1364, in get_result
results = self.func(self.start, self.stop, where)
File "/usr/lib64/python2.7/site-packages/pandas/io/pytables.py", line 673, in func
columns=columns, **kwargs)
File "/usr/lib64/python2.7/site-packages/pandas/io/pytables.py", line 2786, in read
values = self.read_array('block%d_values' % i)
File "/usr/lib64/python2.7/site-packages/pandas/io/pytables.py", line 2327, in read_array
data = node[:]
File "/usr/lib64/python2.7/site-packages/tables/vlarray.py", line 677, in __getitem__
return self.read(start, stop, step)
File "/usr/lib64/python2.7/site-packages/tables/vlarray.py", line 817, in read
outlistarr = [atom.fromarray(arr) for arr in listarr]
File "/usr/lib64/python2.7/site-packages/tables/atom.py", line 1211, in fromarray
return cPickle.loads(array.tostring())
ValueError: unsupported pickle protocol: 4
I've no idea about what this pickle protocol means, and also my colleagues know nothing about it.
我不知道这个泡菜协议是什么意思,我的同事们也对此一无所知。
How can I solve this problem?
我怎么解决这个问题?
I'm using Python 2.7.5 on a CentOS Linux release 7.2.1511 (Core) operating system
我在 CentOS Linux 7.2.1511 (Core) 操作系统上使用 Python 2.7.5
回答by cdarke
The Pickle protocol is basically the file format. From the documentation, The higher the protocol used, the more recent the version of Python needed to read the pickle produced.... Pickle protocol version 4 was added in Python 3.4, your python version (2.7.5) does not support this.
Pickle 协议基本上是文件格式。从文档, 越高所使用的协议,更近的Python的版本需要读取所产生的腌汁。... Pickle 协议版本 4 已添加到 Python 3.4 中,您的 Python 版本 (2.7.5) 不支持此功能。
Either upgrade to Python 3.4 or later (current is 3.5) or create the pickle using a lower protocol (2) in the third parameter to pickle.dump()
.
升级到 Python 3.4 或更高版本(当前为 3.5)或在第三个参数中使用较低的协议 (2) 创建泡菜pickle.dump()
。