A run error caused by naming the Python file with the same name as the system file

Source: Internet
Author: User

#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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.