【发布时间】:2016-12-29 18:59:37
【问题描述】:
我正在尝试在我的代码中实现多处理,因此,我想我会从一些示例开始我的学习。我使用了documentation 中的第一个示例。
from multiprocessing import Pool
def f(x):
return x*x
if __name__ == '__main__':
with Pool(5) as p:
print(p.map(f, [1, 2, 3]))
当我运行上面的代码时,我得到一个AttributeError: can't get attribute 'f' on <module '__main__' (built-in)>。我不知道为什么会收到此错误。如果有帮助,我也在使用 Python 3.5。
【问题讨论】:
-
非常适合我(也在 python 3.5 上)。
-
是的,在 Python 3.5 上也适用于我
-
我应该补充一点,我也在使用 Jupyter Notebook 和 anaconda 作为我的解释器。但 anaconda 使用的是 python 3.5。
-
我在使用 Python 3.6 的 Anaconda 的 Windows 10 上遇到错误。
-
我在常规 python shell windows 10 Python 3.6 上收到错误
标签: python multithreading