当我使用configure_options使用add_file_选项将文件发送到我的节点时,为什么python会冻结?

当我使用configure_options使用add_file_选项将文件发送到我的节点时,为什么python会冻结?,python,python-3.5,mrjob,Python,Python 3.5,Mrjob,我正在尝试使用python中的MRJob包。我想将一个文件(u.item)连同我的代码一起发送到所有节点,因此我使用configure_options函数和add_file_选项告诉python我将在命令行中向您发送一个文件。运行此命令时: !python MostPopularMovieNicer.py--items=u.item u.data 一切都停止了,python冻结了,什么也没给我看 我已运行trace命令,并出现以下错误: TypeError:需要类似字节的对象,而不是“str”

我正在尝试使用python中的MRJob包。我想将一个文件(u.item)连同我的代码一起发送到所有节点,因此我使用configure_options函数和add_file_选项告诉python我将在命令行中向您发送一个文件。运行此命令时: !python MostPopularMovieNicer.py--items=u.item u.data 一切都停止了,python冻结了,什么也没给我看

我已运行trace命令,并出现以下错误: TypeError:需要类似字节的对象,而不是“str”

从mrjob.job导入mrjob 从mrjob.step导入MRStep

MostPopularMovieNicer类(MRJob):

如果name='main': MostPopularMovieNicer.run()


不会显示任何错误,python将冻结。我必须退出该软件才能运行其他代码。

您应该使用配置参数添加文件参数而不是配置选项和添加文件选项。 配置_选项在MRjob中不再可用。 此链接可以帮助您:

def configure_options(self):
    super(MostPopularMovieNicer, self).configure_options()
    self.add_file_option('--items', help='Path to u.item')

def steps(self):
    return [
        MRStep(mapper=self.mapper_get_ratings,
               reducer_init=self.reducer_init,
               reducer=self.reducer_count_ratings),
        MRStep(reducer = self.reducer_find_max)
    ]

def mapper_get_ratings(self, _, line):
    (userID, movieID, rating, timestamp) = line.split('\t')
    yield movieID, 1

def reducer_init(self):
    self.movieNames = {}

    with open("u.ITEM", encoding='ascii', errors='ignore') as f:
        for line in f:
            fields = line.split('|')
            self.movieNames[fields[0]] = fields[1]

def reducer_count_ratings(self, key, values):
    yield None, (sum(values), self.movieNames[key])


def reducer_find_max(self, key, values):
    yield max(values)