Registry / aws / amazon-textract-textractor

amazon-textract-textractor

JSON →
library1.10.0pypypi✓ verified 21d ago

Textractor is a Python package designed to simplify the use of AWS Textract services for document analysis. It provides a higher-level abstraction over the AWS SDK (boto3) to easily extract text, forms, tables, and other data from documents. The library is actively maintained, with frequent minor releases to address bugs and introduce new features.

pip install amazon-textract-textractor
INSTALL
IMPORT
SIG · AMAZON-TEXTRACT-TE
A
amazon-textract-textractor
awspythonv1.10.0
Install
5.8s avg
Import
975ms
Disk
87MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.10.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.910 runs
installs and imports cleanly · install 0.0s · import 1.024s · 91.9MB
glibc
py 3.103.910 runs
installs and imports cleanly · install 5.8s · import 0.926s · 89MB
87MB installed
● package 87MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Textractor
from textractor import Textractor
from amazon_textract_textractor import Textractor
The package name on PyPI is `amazon-textract-textractor`, but the top-level importable module is `textractor`.
Document
from textractor.data.document import Document
The Document class holds the parsed results from Textract.

This quickstart demonstrates how to initialize the Textractor client, process a PDF document located in an S3 bucket using `start_document_analysis` to extract forms and tables, and then print the extracted data. Ensure your AWS credentials and default region are configured for boto3.

import os from textractor import Textractor from textractor.data.constants import TextractFeatures # Ensure AWS credentials are configured (e.g., via AWS CLI, env vars, IAM roles) # textractor uses boto3, which automatically picks up credentials. # Example: os.environ['AWS_ACCESS_KEY_ID'] = 'YOUR_ACCESS_KEY' # os.environ['AWS_SECRET_ACCESS_KEY'] = 'YOUR_SECRET_KEY' # os.environ['AWS_DEFAULT_REGION'] = 'us-east-1' # Initialize Textractor client # Make sure the region matches your S3 bucket and Textract service availability tractor = Textractor(region_name=os.environ.get('AWS_DEFAULT_REGION', 'us-east-1')) # Example: Process a document from an S3 path s3_path = "s3://amazon-textract-public-content/samples/sample.pdf" print(f"Processing document: {s3_path}") document = tractor.start_document_analysis( file_source=s3_path, features=[TextractFeatures.FORMS, TextractFeatures.TABLES] ) # Print extracted forms print("\n--- Forms ---") for key_value in document.key_values: print(f"{key_value.key}: {key_value.value}") # Print extracted tables print("\n--- Tables ---") for i, table in enumerate(document.tables): print(f"Table {i+1}:\n{table.to_csv(include_box=False)}\n")
Debug
Known issues
breakingIn v1.8.3, a breaking change was introduced where `LAYOUT_TABLE` elements generated for HTML output no longer share the same ID as the original `TABLE` prediction. This affects scenarios where you relied on ID matching between Textract's TABLE block and Textractor's HTML representation of the table layout.
fix
Review any code that processes Textractor's HTML output and relies on consistent IDs between the `TABLE` block and the `LAYOUT_TABLE` representation. Adjust your parsing logic to account for this ID divergence if necessary.
affects: >=1.8.3
gotchaProcessing local PDF files requires additional dependencies. While `pypdfium2` is the recommended and automatically installed default for PDF support (via `pip install amazon-textract-textractor[pdf]`), the library might fall back to `pdf2image`. `pdf2image`, in turn, requires Poppler (e.g., `poppler-utils` on Linux, `brew install poppler` on macOS, or pre-compiled binaries on Windows) to be installed on the operating system, which can be a common source of installation issues.
fix
For local PDF processing, always install with `pip install amazon-textract-textractor[pdf]`. If you encounter errors, verify `pypdfium2` is correctly installed and working. If `pdf2image` is used, ensure Poppler is installed and correctly configured in your system's PATH.
affects: All versions
gotchaTextractor relies on `boto3` for AWS authentication and region configuration. Common issues arise from misconfigured AWS credentials (e.g., missing environment variables, incorrect `~/.aws/credentials` file, or IAM role not properly attached/assumed) or specifying an incorrect `region_name` when initializing `Textractor`, leading to 'Access Denied' or 'Region Not Found' errors.
fix
Ensure your AWS credentials are correctly configured for `boto3` (e.g., `AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY`, `AWS_DEFAULT_REGION` environment variables, or `~/.aws/credentials` file). Always specify `region_name` in the `Textractor` constructor, matching the region where your S3 buckets are located and where Textract is available.
affects: All versions
gotchaFor larger documents (e.g., multi-page PDFs), Textract operations are asynchronous. Textractor simplifies this with `start_document_analysis` and `start_document_text_detection` methods, but under the hood, it polls for job completion. Long-running jobs can lead to timeouts or perceived hangs if not handled carefully, and `Textract` service limits should be considered.
fix
Increase the `polling_interval` or `timeout` parameters when calling `start_document_analysis` or `start_document_text_detection` for very large documents if you experience timeouts. Be aware of Textract service limits regarding document size and number of pages.
affects: All versions
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'textractor'
The 'textractor' module is not installed or not found in the Python environment.
fix
Install the module using 'pip install amazon-textract-textractor'.
ImportError: cannot import name 'Textractor' from 'textractor'
The 'Textractor' class is not found in the 'textractor' module, possibly due to an incorrect import statement.
fix
Use the correct import statement: 'from textractor import Textractor'.
FileNotFoundError: [Errno 2] No such file or directory: 'pdfinfo'
The 'pdfinfo' utility from the Poppler package is not installed or not in the system's PATH, which is required for processing PDF files.
fix
Install the Poppler package and ensure its binaries are in the system's PATH.
InvalidS3ObjectException: Amazon Textract is unable to access the S3 object that's specified in the request.
The S3 object specified in the request is inaccessible, possibly due to incorrect permissions or an invalid S3 path.
fix
Verify the S3 object's path and ensure the necessary permissions are set for Amazon Textract to access it.
UnsupportedDocumentException: The format of the input document isn't supported.
The input document is in an unsupported format; Amazon Textract supports PNG, JPEG, PDF, or TIFF formats.
fix
Convert the document to a supported format before processing it with Amazon Textract.
Upgrade
Version history
1.10.0latest on PyPI · released Aug 11, 2026
Audit
Dependencies
boto3requiredRequired for interacting with AWS Textract and S3 services.
pypdfium2optionalUsed for local PDF rasterization when processing local PDF files. Preferred over pdf2image due to fewer external dependencies.
pdf2imageoptionalFallback for local PDF rasterization if pypdfium2 is not available. Requires Poppler to be installed on the system.
Agent activity
54 hits · last 30 days
node
42
OpenAI (training)
3
Perplexity
1
Resources
amazon-textract-textractor — pip install amazon-textract-textractor · libregistry