You can just conver the argument which you are passing in the PyPDFLoader into string like
loader = PyPDFLoader(file_path=str(pdf_path))