#coding =utf-8
From multiprocessing import Process
Import OS
# code to be executed by the child process
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'll start. '
P.start ()
P.join ()
print ' Process end. '
、、、、、、、、、、、、、、、、、、、、、、、、、、、
before saving the above code as multiprocessing.py, error importerror:cannot import name Process, Baidu Error: Because the file name multiprocessing.py and From multiprocessing Import Process conflict, so renamed Mul_pro_test.py.
after running, there is still an error
Traceback (most recent):
File "D:\Python\mul_pro_test.py", line 2, <module>
From multiprocessing import Process
File "D:\Python\multiprocessing.py", line 2, <module>
Importerror:cannot Import Name Process
The strange thing is:file "D:\Python\multiprocessing.py", Line 2, in <module>, I have modified the file name, why multiprocessing.py also reported wrong /c1>
go to Folder to view the original more than one multiprocessing.py compiled multiprocessing.pyc file, delete Multiprocessing.pyc file, run successfully. original article path: http://blog.csdn.net/wukai0909/article/details/52737985
A run error caused by naming the Python file with the same name as the system file