在多处理文件中导入错误

时间:2018-04-17 16:37:18

标签: python-2.7

我正在尝试使用python多处理模块处理大文件。执行下面的代码我得到模块导入错误。 在python2.7控制台上,“来自多处理导入池”工作正常。

from multiprocessing import Pool
import subprocess

def process_line(file):
    return "foo"

if __name__ == "__main__":
   pool = Pool(4)
   with open('file.txt') as source_file:
    # chunk the work into batches of 4 lines at a time
       results = pool.map(process_line, source_file, 4)

   print results

导入错误: enter image description here

0 个答案:

没有答案