要解决的技巧:TypeError:需要一个类似字节的对象,而不是'str'

时间:2017-03-10 18:20:08

标签: python python-3.x

我知道还有其他问题,但我没有找到适合我的问题的答案。

所以我收到以下错误: TypeError:需要类似字节的对象,而不是'str'

Traceback (most recent call last):
  File "/Users/danvdb/anaconda/bin/mrec_predict", line 9, in <module>
    load_entry_point('mrec==0.3.1', 'console_scripts', 'mrec_predict')()
  File "/Users/danvdb/anaconda/lib/python3.5/site-packages/mrec-0.3.1-py3.5-macosx-10.5-x86_64.egg/mrec/examples/predict.py", line 227, in main
    description,metrics = process(view,opts,modelfile,trainfile,testfile,opts.item_features,opts.outdir,evaluator)
  File "/Users/danvdb/anaconda/lib/python3.5/site-packages/mrec-0.3.1-py3.5-macosx-10.5-x86_64.egg/mrec/examples/predict.py", line 63, in process
    processed = [r.get() for r in results]
  File "/Users/danvdb/anaconda/lib/python3.5/site-packages/mrec-0.3.1-py3.5-macosx-10.5-x86_64.egg/mrec/examples/predict.py", line 63, in <listcomp>
    processed = [r.get() for r in results]
  File "/Users/danvdb/anaconda/lib/python3.5/site-packages/ipyparallel/client/asyncresult.py", line 167, in get
    raise self.exception()
  File "/Users/danvdb/anaconda/lib/python3.5/site-packages/ipyparallel/client/asyncresult.py", line 226, in _resolve_result
    results = error.collect_exceptions(results, self._fname)
  File "/Users/danvdb/anaconda/lib/python3.5/site-packages/ipyparallel/error.py", line 233, in collect_exceptions
    raise e
  File "/Users/danvdb/anaconda/lib/python3.5/site-packages/ipyparallel/error.py", line 231, in collect_exceptions
    raise CompositeError(msg, elist)
ipyparallel.error.CompositeError: one or more exceptions from call to method: run
[3:apply]: TypeError: a bytes-like object is required, not 'str'

代码如下(来自predict.py):

results = []
results.append(view.map_async(predict.run,tasks,retries=2))

# wait for tasks to complete
processed = [r.get() for r in results]

感谢您的帮助:)

0 个答案:

没有答案