Python Forum
python 3: TypeError: a bytes-like object is required, not 'str'
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
python 3: TypeError: a bytes-like object is required, not 'str'
#2
subprocess.check_output(['ps', 'uaxw']).splitlines()
Will output raw bytes because the encoding is missing.
This is the default behavior.

subprocess.check_output(['ps', 'uaxw'], encoding="utf8").splitlines()
Will decode as utf8 and return a str.

Docs: https://docs.python.org/3/library/subpro...eck_output
Almost dead, but too lazy to die: https://sourceserver.info
All humans together. We don't need politicians!
Reply


Messages In This Thread
RE: python 3: TypeError: a bytes-like object is required, not 'str' - by DeaD_EyE - Jul-09-2021, 08:59 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  TypeError: cannot pickle ‘_asyncio.Future’ object Abdul_Rafey 1 413 Mar-07-2024, 03:40 PM
Last Post: deanhystad
  error in class: TypeError: 'str' object is not callable akbarza 2 525 Dec-30-2023, 04:35 PM
Last Post: deanhystad
Bug TypeError: 'NoneType' object is not subscriptable TheLummen 4 762 Nov-27-2023, 11:34 AM
Last Post: TheLummen
  TypeError: 'NoneType' object is not callable akbarza 4 1,022 Aug-24-2023, 05:14 PM
Last Post: snippsat
  [NEW CODER] TypeError: Object is not callable iwantyoursec 5 1,394 Aug-23-2023, 06:21 PM
Last Post: deanhystad
  TypeError: 'float' object is not callable #1 isdito2001 1 1,092 Jan-21-2023, 12:43 AM
Last Post: Yoriz
  TypeError: a bytes-like object is required ZeroX 13 4,191 Jan-07-2023, 07:02 PM
Last Post: deanhystad
  TypeError: 'float' object is not callable TimofeyKolpakov 3 1,476 Dec-04-2022, 04:58 PM
Last Post: TimofeyKolpakov
  API Post issue "TypeError: 'str' object is not callable" makeeley 2 1,936 Oct-30-2022, 12:53 PM
Last Post: makeeley
  "SUMIF" type query in Python (help required) BlainEillimatta 0 859 Oct-06-2022, 09:08 AM
Last Post: BlainEillimatta

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020