[英]python NameError: global name 'multiprocessing' is not defined
I am trying to convert my threaded code to multiprocessing code. 我正在尝试将线程代码转换为多处理代码。 but it is giving me error
但这给了我错误
Name Error: global name 'multiprocessing' is not defined
Multiprocessing is installed and I imported it by 安装了多处理程序,我通过导入它
from multiprocessing import *
With your import, you will import everything inside the multiprocessing
module. 导入后,您将在
multiprocessing
模块中导入所有内容。 I assume that you are making a call that looks something like 我假设您拨打的电话看起来像
multiprocessing.some_function()
but since you've imported everything inside multiprocessing
, it will not be in your namespace. 但是由于您已将所有内容都导入到
multiprocessing
,因此不会将其放在您的名称空间中。 I recommend that you do import multiprocessing
and use that as your point of entry to not clutter your namespace. 我建议您确实
import multiprocessing
并将其用作切入点,以免使您的名称空间混乱。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.