p looks like a pathlib Path, not an os path.
Hard to be sure without full code.
Hard to be sure without full code.
dir = "E:\\Books" p = Path(dir)if that is the case, then you can still use os, but you must resolve p first:
os.walk(p.resolve())better to use a pathlib walk instead (Google: 'pathlib equivalent of os.walk')