AttributeError: module ‘os’ has no attribute ‘fork’ 原因与解决方法
今天在看Python多进程的时候,在Windows上运行Python代码的时候,结果出现了如下错误:
AttributeError: module 'os' has no attribute 'fork'
中文翻译
AttributeError:模块“ os”没有属性“ fork”
而我直接在Linux上运行,却又不会出现这个错误,如下图:
经过一番资料查找,到了具体的原因,如下:
由于Windows没有fork调用,上面的代码在Windows上无法运行。因此,建议 os.fork() 不要在windows系统上用。
如果想要有fork调用,推荐大家用Unix/Linux或mac系统的电脑。