import os
import openai
import sys
sys.path.append('../..')
from dotenv import load_dotenv, find_dotenv
_=load_dotenv(find_dotenv())
openai.api_key ="my_key"
from langchain.document_loaders import PyPDFLoader
loader = PyPDFLoader("C:\\Users\\LENOVO\\Documents\\MachineLearning-Lecture01.pdf")
In my code, I've made sure to use the 'r'
prefix to treat backslashes as literal characters in the file path, used double backslashes to escape them properly, and double-checked that the file indeed exists at the specified location "C:\Users\LENOVO\Desktop\MachineLearning-Lecture01.pdf."
However, despite these precautions, I'm consistently receiving a 'ValueError' stating that the file path is not recognized as a valid file or URL when using the PyPDFLoader.
How to resolve this issue and successfully load the PDF file?
To address the issue, I uploaded the file directly to Google Colab and then utilized the following line of code to read it:
loader = PyPDFLoader("MachineLearning-Lecture01.pdf")
This allowed me to access and work with the file in Colab seamlessly.