我正在努力让ipyparallel工作。我正在跟踪
Getting Stared guide
但基本功能在我的机器上不起作用。
我从命令行启动集群
ipcluster start -n 4
然后我运行脚本:
import ipyparallel as ipp
c=ipp.Client()
print(c[:].apply_sync(lambda : "Hello, World"))
在Python3中,它可以按预期工作,但在Python2中运行时却不能。我得到错误:
TypeError: an integer is required (got type str)
此外,当我在Jupyter笔记本中使用python 2和python 3内核运行该代码段时,我得到了相同的错误。
知道我为什么会犯这个错误吗?谢谢
编辑:
jupyter中的总错误为:
Traceback (most recent call last)~/.local/lib/python3.5/site-packages/ipyparallel/serialize/serialize.py in unpack_apply_message(bufs, g, copy)
185 assert len(bufs) >= 2, "not enough buffers!"
186 pf = buffer_to_bytes_py2(bufs.pop(0))
--> 187 f = uncan(pickle.loads(pf), g)
188 pinfo = buffer_to_bytes_py2(bufs.pop(0))
189 info = pickle.loads(pinfo)
~/.local/lib/python3.5/site-packages/ipyparallel/serialize/codeutil.py in code_ctor(*args)
22
23 def code_ctor(*args):
---> 24 return types.CodeType(*args)
25
26 def reduce_code(co):
TypeError: an integer is required (got type str)
我正在使用Python3.5.2和Python2.7.12以及ipyparallel v6.0.2。我发现ipyparallel v6不需要>Python3,虽然我在
docs
,所以我很高兴这只适用于Python3。