2021年3月30日星期二

TypeError: a bytes-like object is required, not 'str' in Python3

I am trying to use a python script from https://github.com/clab/fast_align and get an error at this line: https://github.com/clab/fast_align/blob/cab1e9aac8d3bb02ff5ae58218d8d225a039fa11/src/force_align.py#L30

Traceback (most recent call last):    File "force_align.py", line 96, in <module>      main()    File "force_align.py", line 90, in main      sys.stdout.write('{}\n'.format(aligner.align(line.strip())))    File "force_align.py", line 30, in align      self.fwd_align.stdin.write('{}\n'.format(line))  TypeError: a bytes-like object is required, not 'str'  

I have full verified that the input/output files are correct but no fix is helping solve this error. I tried encode() on line 30, I tried encode('utf-8') but nothing is helping solve the problem.

Any ideas or help is greatly appreciated. Thank you :)

https://stackoverflow.com/questions/66881103/typeerror-a-bytes-like-object-is-required-not-str-in-python3 March 31, 2021 at 11:07AM

没有评论:

发表评论