TypeError: expected str, bytes or os.PathLike object, not tuple with os.path.basename TypeError: expected str, bytes or os.PathLike object, not tuple with os.path.basename tkinter tkinter

TypeError: expected str, bytes or os.PathLike object, not tuple with os.path.basename


The error is because of the following:

  • askopenfilenames returns a tuple of filenames, even if there's only one
  • you are passing the result of askopenfilenames to os.path.basename, but that function expects a single filename

That is why you get the error expected str, bytes, or os.PathLike object, not tuple: you are passing a tuple and the error message says you can't do that.