Python jupyter笔记本中的multiprocessing.Pool可以在linux上工作,但不能在windows上工作

Python jupyter笔记本中的multiprocessing.Pool可以在linux上工作,但不能在windows上工作,python,python-2.7,python-multiprocessing,jupyter,Python,Python 2.7,Python Multiprocessing,Jupyter,我正在尝试运行一些独立的计算(尽管从相同的数据中读取)。我的代码在Ubuntu上运行时有效,但在Windows(Windows server 2012 R2)上不起作用,我在Windows上遇到错误: “模块”对象没有属性… 当我尝试使用多处理.Pool时(它出现在内核控制台中,而不是作为笔记本本身的输出) (我已经犯了在创建池之后定义函数的错误,并且我也纠正了它,这不是问题所在) 即使在最简单的示例中也会出现这种情况: from multiprocessing import Pool def

我正在尝试运行一些独立的计算(尽管从相同的数据中读取)。我的代码在Ubuntu上运行时有效,但在Windows(Windows server 2012 R2)上不起作用,我在Windows上遇到错误:

“模块”对象没有属性…

当我尝试使用
多处理.Pool
时(它出现在内核控制台中,而不是作为笔记本本身的输出)

(我已经犯了在创建池之后定义函数的错误,并且我也纠正了它,这不是问题所在)

即使在最简单的示例中也会出现这种情况:

from multiprocessing import Pool
def f(x):
    return x**2
pool = Pool(4)
for res in pool.map(f,range(20)):
    print res
我知道它需要能够导入模块(在笔记本电脑中工作时我不知道这是如何工作的),我也听说过
IPython.Parallel
,但我找不到任何文档或示例


任何解决方案/备选方案都是最受欢迎的。

我会将此作为评论发布,因为我没有完整的答案,但我会在了解情况后进行修改

from multiprocessing import Pool

def f(x):
    return x**2

if __name__ == '__main__':
    pool = Pool(4)
    for res in pool.map(f,range(20)):
        print(res)
这很有效。我相信这个问题的答案是。简而言之,子流程不知道它们是子流程,并且正在尝试递归地运行主脚本

这就是我得到的错误,它给了我们相同的解决方案:

RuntimeError: 
        An attempt has been made to start a new process before the
        current process has finished its bootstrapping phase.

        This probably means that you are not using fork to start your
        child processes and you have forgotten to use the proper idiom
        in the main module:

            if __name__ == '__main__':
                freeze_support()
                ...

        The "freeze_support()" line can be omitted if the program
        is not going to be frozen to produce an executable.

完全正确。事实上,这些文档详细说明了Windows上多处理的几个问题。看见