To extract text from a PDF file using Python, you can use the PyPDF2 library. It provides methods to open a PDF file, read its contents, and extract text from each page. Alternatively, you can use PDFMiner library to achieve the same task.