python 3 subprocess error in bytes python 3 subprocess error in bytes python-3.x python-3.x

python 3 subprocess error in bytes


o, the first return value from proc.communicate(), is already bytes not str, so it is already encoded in some encoding (or you could think of it as just a sequence of bytes).

In Python3 bytes can be decoded to str, and str can be encoded to bytes, but bytes can never be encoded, and str can never be decoded. That is why Python3 is complaining,

AttributeError: 'bytes' object has no attribute 'encode'