TypeError: a bytes-like object is required, not 'str' in subprocess.check_output TypeError: a bytes-like object is required, not 'str' in subprocess.check_output python-3.x python-3.x

TypeError: a bytes-like object is required, not 'str' in subprocess.check_output


Decode before using split funtion

Null,userprof = subprocess.check_output('set USERPROFILE', shell=True).decode('utf-8').split('=')


Another solution is adding text=True to check_output:

path = os.getcwd().strip('/n') Null,userprof = subprocess.check_output('set USERPROFILE', shell=True, text=True).split('=')