Answer the question
In order to leave comments, you need to log in
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 382: invalid start byte, what to do?
subprocess is trying to execute the command and output the result, but then display an error:
def execute(command):
return subprocess.check_output(command, shell = True, encoding = 'utf-8')
Traceback (most recent call last):
File "C:\Users\maksa\Desktop\My Files\vidstream\client.py", line 34, in <module>
result = execute(cmd_data)
File "C:\Users\maksa\Desktop\My Files\vidstream\client.py", line 17, in execute
return subprocess.check_output(command, shell = True, encoding = 'utf-8')
File "C:\Program Files\Python39\lib\subprocess.py", line 424, in check_output
return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
File "C:\Program Files\Python39\lib\subprocess.py", line 507, in run
stdout, stderr = process.communicate(input, timeout=timeout)
File "C:\Program Files\Python39\lib\subprocess.py", line 1121, in communicate
stdout = self.stdout.read()
File "C:\Program Files\Python39\lib\codecs.py", line 322, in decode
(result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 382: invalid start byte
Answer the question
In order to leave comments, you need to log in
Try to add after
return subprocess.check_output(command, shell = True, encoding = 'utf-8')
.content.decode('Windows-1251')
def execute(command):
return subprocess.check_output(command, shell = True).content.decode('Windows-1251')
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question