Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ModuleNotFoundError: No module named '_lzma' #339

Closed
nikunjgoel95 opened this issue Apr 22, 2024 · 4 comments
Closed

ModuleNotFoundError: No module named '_lzma' #339

nikunjgoel95 opened this issue Apr 22, 2024 · 4 comments

Comments

@nikunjgoel95
Copy link

nikunjgoel95 commented Apr 22, 2024

Stacktrace

  File "/Users/nikunj.goel/work/virtual_environments/gpt/lib/python3.10/site-packages/unstructured/partition/auto.py", line 423, in partition
    elements = _partition_pdf(
  File "/Users/nikunj.goel/work/virtual_environments/gpt/lib/python3.10/site-packages/unstructured/documents/elements.py", line 559, in wrapper
    elements = func(*args, **kwargs)
  File "/Users/nikunj.goel/work/virtual_environments/gpt/lib/python3.10/site-packages/unstructured/file_utils/filetype.py", line 622, in wrapper
    elements = func(*args, **kwargs)
  File "/Users/nikunj.goel/work/virtual_environments/gpt/lib/python3.10/site-packages/unstructured/file_utils/filetype.py", line 582, in wrapper
    elements = func(*args, **kwargs)
  File "/Users/nikunj.goel/work/virtual_environments/gpt/lib/python3.10/site-packages/unstructured/chunking/dispatch.py", line 83, in wrapper
    elements = func(*args, **kwargs)
  File "/Users/nikunj.goel/work/virtual_environments/gpt/lib/python3.10/site-packages/unstructured/partition/pdf.py", line 219, in partition_pdf
    return partition_pdf_or_image(
  File "/Users/nikunj.goel/work/virtual_environments/gpt/lib/python3.10/site-packages/unstructured/partition/pdf.py", line 310, in partition_pdf_or_image
    elements = _partition_pdf_or_image_local(
  File "/Users/nikunj.goel/work/virtual_environments/gpt/lib/python3.10/site-packages/unstructured/utils.py", line 220, in wrapper
    return func(*args, **kwargs)
  File "/Users/nikunj.goel/work/virtual_environments/gpt/lib/python3.10/site-packages/unstructured/partition/pdf.py", line 411, in _partition_pdf_or_image_local
    from unstructured_inference.inference.layout import (
  File "/Users/nikunj.goel/work/virtual_environments/gpt/lib/python3.10/site-packages/unstructured_inference/inference/layout.py", line 20, in <module>
    from unstructured_inference.models.base import get_model
  File "/Users/nikunj.goel/work/virtual_environments/gpt/lib/python3.10/site-packages/unstructured_inference/models/base.py", line 9, in <module>
...
    import lzma
  File "/Users/nikunj.goel/.pyenv/versions/3.10.13/lib/python3.10/lzma.py", line 27, in <module>
    from _lzma import *
ModuleNotFoundError: No module named '_lzma'

Version 0.12.5 works perfectly and all the versions after that give the same error.
Codeblock I am using

def load_single_document(file_path: str) -> Optional[Document]:
    """Load a single document from a file path."""
    try:
        elements = partition(filename=file_path)
        logger.debug(f"{file_path} loaded.")
        document_content = "\n\n".join([str(el) for el in elements])
        langchain_doc = Document(page_content=document_content, metadata={"source": file_path})
        return langchain_doc
    except FileNotFoundError:
        logger.error(f"File not found: {file_path}")
    except IOError:
        logger.error(f"Input/Output error when loading {file_path}")
    except Exception as ex:
        logger.error(f"Unexpected error loading {file_path}: {ex}", exc_info=True)
    return None

System : Apple M2
Os : 14.3.1

@nikunjgoel95
Copy link
Author

nikunjgoel95 commented Apr 22, 2024

brew install xz is also installed too.

@scanny
Copy link
Contributor

scanny commented Apr 24, 2024

@nikunjgoel95 unfortunately the stack trace you provided is missing the lines I need, those are elided with the ....

Can you provide the entire stack trace?

@scanny
Copy link
Contributor

scanny commented Apr 24, 2024

However some research indicates this is a problem with your installed Python. You need to rebuild your Python after installing xz, depending on how you installed it. This gist has some more information: https://gist.github.com/iandanforth/f3ac42b0963bcbfdf56bb446e9f40a33

@scanny
Copy link
Contributor

scanny commented Apr 24, 2024

Closing as resolved. @nikunjgoel95 let us know if it's still giving you trouble :)

@scanny scanny closed this as completed Apr 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants