pickle.PicklingError: Can't pickle <function <lambda>
2016-09-15 22:21
1036 查看
1 出现该异常的原因是pickle模块不能序列化lambda function.查看下面的链接可知pickle模块可序列那些类型
https://docs.python.org/3/library/pickle.html#what-can-be-pickled-and-unpickled
2 解决方案
https://github.com/uqfoundation/dill 使用pickle的替代者
3 使用demo
import dill
if __name__ == "__main__":
s = dill.dumps(lambda x, y: x+y)
f = dill.loads(s)
assert f(3,4) == 7
https://docs.python.org/3/library/pickle.html#what-can-be-pickled-and-unpickled
2 解决方案
https://github.com/uqfoundation/dill 使用pickle的替代者
3 使用demo
import dill
if __name__ == "__main__":
s = dill.dumps(lambda x, y: x+y)
f = dill.loads(s)
assert f(3,4) == 7
相关文章推荐
- python3 PicklingError: Can't pickle <function <lambda> at......> attribute lookup <lambda> on __main
- PicklingError: Can't pickle <type 'thread.lock'>: attribute lookup thread.lock failed
- python multiprocessing.Pool - PicklingError: Can't pickle <type 'instancemethod'>: attribute lookup __builtin__.instancemethod failed
- 调查 PicklingError: Can't pickle <type 'instancemethod'>: attribute lookup __builtin__.instancemethod failed
- PicklingError: Can't pickle <type 'generator'>: it's not found as __builtin_
- python2,socket多进程的错误pickle.PicklingError: Can't pickle <built-in method recvfrom_into of _socket.soc
- Qt error ------ no matching function for call to QObject::connect(QSpinBox*&, <unresolved overloaded function type>, QSlider*&, void (QAbstractSlider::*)(int))
- error: no matching function for call to ‘boost::thread::thread(<unresolved overloaded function type>
- 关于 "Uncaught TypeError: Property 'submit' of object #<HTMLFormElement> is not a function" 的解决方案
- JNI DETECTED ERROR IN APPLICATION: can't call void XXX on instance of java.lang.Class <XXX>解决方案
- error: no matching function for call to ‘ptr_fun(<unresolved overloaded function type>)’
- error: no matching function for call to 'std::basic_ifstream<char>::open(std::string&)
- error "Can only specify query options (orderby, where, take, skip) after last navigation" when fetching a List<string>
- Celery: Unrecoverable error: AttributeError(“Can't pickle local object 'Pool.__init__.<locals
- vim 的一个错误。Error detected while processing function <SNR>25_updateData..fuf#updateMruList
- 使用SiftGPU遇到问题:freeglut ERROR: Function <glutDestroyWindow> called without first calling 'glutInit'.
- opencv error:assertion failed<src.cols>0&&src.rows>0>in unknown function
- python multiprocessing.Pool - UnpickleableError: Cannot pickle <type 'thread.lock'> objects
- mysql错误:ERROR 1005<HY000> Can't creat table `table_name` <erron:150>
- JNI DETECTED ERROR IN APPLICATION: can't call void XXX on instance of java.lang.Class <XXX>解决方案