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]

posted @ 2019-03-23 12:14  hank-li  阅读(1433)  评论(0编辑  收藏  举报