Skip to content

PermissionError when parsing multiple PDFs on Windows with Camelot #678

@pavelwolf999

Description

@pavelwolf999

Describe the bug

I’m using Camelot to parse multiple PDFs on Windows 11 with Python 3.13.5. When processing several files, I get a PermissionError related to temporary files. It seems to occur when Camelot tries to clean up temporary directories after reading PDFs.

Exception ignored in atexit callback <function rmtree at 0x...>:
Traceback (most recent call last):
  File "C:\Python313\Lib\shutil.py", line 790, in rmtree
    return _rmtree_unsafe(path, onexc)
  File "C:\Python313\Lib\shutil.py", line 635, in _rmtree_unsafe
    onexc(os.rmdir, path, err)
  File "C:\Python313\Lib\shutil.py", line 631, in _rmtree_unsafe
    os.rmdir(path)
PermissionError: [WinError 5] Access is denied: '<temp_file_path>'

Steps to reproduce the bug

Expected behavior

All PDFs should parse successfully without PermissionError. Temporary files should be cleaned up automatically.

Code

import camelot
from pathlib import Path
import os

PDF_FOLDER = Path(r"C:\path\to\your\pdfs")  # replace with actual folder on your system

for pdf in os.listdir(PDF_FOLDER):
    pdf_path = PDF_FOLDER / pdf
    print(pdf_path)

    tables = camelot.read_pdf(
        pdf_path,
        pages="1",
        flavor="lattice"
    )

PDF

sample-tables.pdf
sample-tables_2.pdf

Screenshots

Environment

  • OS: Windows-11-10.0.26100-SP0
  • Python version: 3.13.5 (tags/v3.13.5:6cb20a2, Jun 11 2025, 16:15:46) [MSC v.1943 64 bit (AMD64)]
  • Numpy version: 2.2.6
  • OpenCV version: 4.12.0
  • Ghostscript version: not installed
  • camelot version: 1.0.9

Additional context

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions