Pathos多处理池CPickle错误

时间:2017-05-21 08:48:41

标签: python multiprocessing pathos

当我尝试运行以下代码时:

from pathos.multiprocessing import ProcessingPool as Pool
list1 = [1,2,3,4,5]
list2 = [6,7,8,9,10]
def function1(x,y):
    print x
    print y
if __name__ == '__main__':
    pool = Pool(5)
    pool.map(function1, list1, list2)

它得到了跟随错误:

Traceback (most recent call last):
  File "test.py", line 9, in <module>
    pool.map(function1, list1, list2)
  File "C:\Python27\lib\site-packages\pathos\multiprocessing.py", line 136, in map
    return _pool.map(star(f), zip(*args)) # chunksize
  File "C:\Python27\lib\site-packages\multiprocess\pool.py", line 251, in map
    return self.map_async(func, iterable, chunksize).get()
  File "C:\Python27\lib\site-packages\multiprocess\pool.py", line 567, in get
    raise self._value
cPickle.PicklingError: Can't pickle <type 'function'>: attribute lookup __builtin__.function failed

是不是pathos.multiprocessing旨在解决这个问题?

1 个答案:

答案 0 :(得分:1)

我是pathos作者。当我尝试你的代码时,我没有收到错误。但是,如果您看到CPickle.PicklingError,我猜您在安装multiprocess时遇到问题。你在Windows上,所以你有一个C编译器吗?您需要multiprocess一个才能完整安装multiprocess