ImportError: cannot import name 'Process' from 'multiprocessing'

Posted hankleo

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ImportError: cannot import name 'Process' from 'multiprocessing'相关的知识,希望对你有一定的参考价值。

from multiprocessing import Process

import os


def run_proc(name):
print Run child process %s (%s)... % (name, os.getpid())


if __name__==__main__:
    print Parent process %s. % os.getpid()
    p = Process(target=run_proc, args=(test,))
    print Process will start.
    p.start()
    p.join()

    print Process end.

 

但是报错

ImportError: cannot import name ‘Process‘

查询后是由于.py文件名multiprocessing冲突,于是修改文件名,并删除之前编译所生成的multiprocess.pyc文件,运行成功。

Parent process 16572.
Process will start.
Run child process test (16575)...
Process end.
[Finished in 0.1s]

以上是关于ImportError: cannot import name 'Process' from 'multiprocessing'的主要内容,如果未能解决你的问题,请参考以下文章

解决 ImportError: cannot import name pywrap_tensorflow

ImportError: cannot import name webdriver

ImportError: cannot import name patterns

window环境下ImportError: cannot import name 'Bar' from 'pyecharts'

ImportError: cannot import name 'DjangoSuitConfig'

ImportError: cannot import name ‘DtypeArg‘ from ‘pandas