我有一个与此类似的问题 person .我无法在pathos模块中运行一个简单的多处理例程,并收到一个pickling错误。 下面是代码和错误。
from pathos.multiprocessing import ProcessingPool
import dill
class ProcClass(object):
def __init__(self):
def f(self,x):
return x*x
pc = ProcClass()
pl = ProcessingPool(3)
print pl.map(pc.f, range(10))
The returned error:
Exception in thread Thread-2:
Traceback (most recent call last):
File "/Library/Frameworks/EPD64.framework/Versions/7.3/lib/python2.7/threading.py", line 551, in __bootstrap_inner
self.run()
File "/Library/Frameworks/EPD64.framework/Versions/7.3/lib/python2.7/threading.py", line 504, in run
self.__target(*self.__args, **self.__kwargs)
File "/Library/Frameworks/EPD64.framework/Versions/7.3/lib/python2.7/multiprocessing/pool.py", line 320, in _handle_tasks
put(task)
PicklingError: Can't pickle <type 'function'>: attribute lookup __builtin__.function failed
我已经安装了:pp、dill、pox和multiprocessing,然后安装了pathos。安装工作正常,但总是给我这样的错误。
WARNING: One of the following dependencies is unresolved:
pp(ft) >=1.6.4.5
dill >=0.2.4
pox >=0.2.2
(multi)processing
根据pathos的作者对一个类似问题的回应,看起来安装时有问题。我已经删除并重新安装了好几次,每次都验证了正确的依赖关系已经安装。我在MacOS上运行,使用python 2.7。
如果有任何帮助,我将不胜感激