[BUG: Breaking] Import Error
Author: aniket-professional2025Created Jul 13, 2026Updated Jul 13, 2026
Labelsbug: breaking
Describe the Bug
While importing the inference module from surya (after pip installing the version 0.21.0), it gives module not found error
Input Document
Output Trace / Stack Trace
Click to expandTraceback (most recent call last):
File "C:\Users\Webbies\Jupyter_Notebooks\Bank_Accounting_Agent\ocr_test.py", line 79, in <module>
from surya.inference import SuryaInferenceManager
ModuleNotFoundError: No module named 'surya.inference'⚙️ Environment
Please fill in all relevant details:
- Marker version: 2.1.5
- Surya version: 0.21.1
- Python version: 3.12.13
- PyTorch version: 2.8.0+cu126
- Transformers version: 5.13.1
- Operating System (incl. container info if relevant): Windows
✅ Expected Behavior
What did you expect Marker to do?
Command or Code Used
Paste the exact bash command or Python code you used to run Marker:
Click to expandimport os
from PIL import Image
from pdf2image import convert_from_path
from markdownify import markdownify as md
from surya.inference import SuryaInferenceManager
from surya.layout import LayoutPredictor
from surya.recognition import RecognitionPredictor
def pdf_to_markdown(pdf_path):
print("Initializing Surya Inference Manager...")
# Initialize the core manager and predictors
manager = SuryaInferenceManager()
layout_predictor = LayoutPredictor(manager)
recognition_predictor = RecognitionPredictor(manager)
print(f"Converting PDF pages to images: {pdf_path}")
pages = convert_from_path(pdf_path, dpi=150)
markdown_content = []
print("Starting OCR and layout processing...")
for page_num, page_image in enumerate(pages):
# 1. Predict layout to preserve proper reading order structure
layout_results = layout_predictor([page_image])
# 2. Run block-mode OCR using the detected layout
ocr_results = recognition_predictor([page_image], layout_results)
# 3. Extract blocks from the page result
page_ocr = ocr_results[0]
markdown_content.append(f"<!-- START OF PAGE {page_num + 1} -->\n\n")
# Blocks are returned pre-sorted in their correct reading order
for block in page_ocr.blocks:
# If the block doesn't contain text/HTML (e.g., a pure picture), skip it
if block.skipped or not block.html:
continue
# Convert Surya's block HTML directly into Markdown format
block_markdown = md(block.html, heading_style="ATX").strip()
if block_markdown:
markdown_content.append(block_markdown + "\n\n")
markdown_content.append(f"<!-- END OF PAGE {page_num + 1} -->\n\n---\n\n")
# Combine all pieces and print directly to the terminal
final_markdown = "".join(markdown_content)
print("\n--- RENDERED MARKDOWN OUTPUT ---\n")
print(final_markdown)
if __name__ == "__main__":
# Replace with your actual file paths
INPUT_PDF = r"./Sample_Resources/Statements/INDUSIND_SMALL.pdf"
if os.path.exists(INPUT_PDF):
pdf_to_markdown(INPUT_PDF)
else:
print(f"Error: Could not find the file {INPUT_PDF}. Please update the path.")Additional Context
Any other context that might help us debug this (e.g., CLI options, working directory, runtime settings).
Source: datalab-to/surya