小编use*_*060的帖子

Python多处理错误:AttributeError:模块'__main__'没有属性'__spec__'

我正在使用Python 3.6,并且正在尝试跟随下面网站上的第一个示例(下面的完整代码)并且我得到以下错误:https: //docs.python.org/3.6/library/multiprocessing. HTML

错误信息: AttributeError: module '__main__' has no attribute '__spec__'

完整示例代码:

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]))
Run Code Online (Sandbox Code Playgroud)

我尝试使用Google搜索并搜索Stack Overflow,但我只发现了另一个此错误的情况并且没有答案.

python multiprocessing spyder python-multiprocessing

17
推荐指数
2
解决办法
1万
查看次数