I was able to dump the contents of spec and assign them to a variable that was included inside main to allow this code to function within the IPython console.from multiprocessing import Pooldef f(x): return x*xif __name__ == '__main__': __spec__ = "ModuleSpec(name='builtins', loader=<class '_frozen_importlib.BuiltinImporter'>)" with Pool(5) as p: print (p.map(f, [1, 2, 3])) 这篇关于Python多重处理错误:AttributeError:模块'__main__'没有属性'__spec__'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
05-26 13:28
查看更多