Windows 10 x64运行pdf-diff工具时触发FileNotFoundError求助
I get it—dealing with FileNotFoundError: [WinError 2] in subprocess.py when trying to run pdf-diff is frustrating, especially since you’ve already reached out to the repo maintainers without a response yet. Let’s walk through the most likely causes and fixes for this issue on your setup.
Why This Happens
This error almost always means the subprocess module can’t locate an external executable that pdf-diff depends on. Under the hood, pdf-diff uses tools like pdftotext (part of the Poppler PDF toolkit) to parse PDFs. The problem is probably one of two things:
- The required Poppler binaries aren’t installed on your system, or
- Your 32-bit Python instance can’t find the binaries in your system PATH (a common mismatch on 64-bit Windows).
Fixes to Try
Install 32-bit Poppler for Windows
Since you’re running 32-bit Python, you need the matching 32-bit version of Poppler to avoid architecture conflicts. Download it, extract the files to a folder likeC:\Poppler\, then add thebinsubfolder (e.g.,C:\Poppler\bin) to your system’s PATH environment variable. Don’t forget to restart your Command Prompt or terminal to pick up the new PATH changes.Verify pdftotext is accessible
Open a fresh Command Prompt and runpdftotext --version. If this returns version details, you know the tool is correctly added to PATH. If not, double-check your PATH entry or restart your PC to ensure the changes take effect.Hardcode the pdftotext path in pdf-diff
If adding to PATH doesn’t work, you can modify the pdf-diff code to point directly to the executable. Look for the line in the code wheresubprocesscallspdftotext, and replace the executable name with the full Windows path (including the.exeextension), like this:subprocess.run([r"C:\Poppler\bin\pdftotext.exe", your_pdf_path, output_path])Adjust the path to match where you installed Poppler.
Upgrade to a newer Python version (if feasible)
Python 3.6 is end-of-life and lacks support for newer Windows features. While you tried both 32 and 64-bit 3.6 versions, upgrading to a supported 64-bit Python release (like 3.8 or later, matching your 64-bit OS) could resolve compatibility issues withsubprocessand external tools. Just remember to reinstall pdf-diff and its dependencies after upgrading.
If none of these steps work, take a closer look at the exact line in subprocess.py that’s failing—sometimes tools hardcode executable names without the .exe extension, which trips up Windows. You might need to add .exe to the executable name in the pdf-diff code.
内容的提问来源于stack exchange,提问作者Mohammad Taksokhan

