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]