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

ImportError: failed to find libmagic. Check your installation #975

Open
NAMEs opened this issue Dec 27, 2024 · 2 comments
Open

ImportError: failed to find libmagic. Check your installation #975

NAMEs opened this issue Dec 27, 2024 · 2 comments

Comments

@NAMEs
Copy link

NAMEs commented Dec 27, 2024

backend error:
ImportError: failed to find libmagic. Check your installation

info:
mac m1
ollama qwen:32b

[ERROR]{'message': 'Failed To Process File:book.txt or LLM Unable To Parse Content ', 'error_message': 'Error while reading the file content or metadata', 'file_name': 'book.txt', 'status': 'Failed', 'db_url': 'neo4j://127.0.0.1:7687', 'failed_count': 1, 'source_type': 'local file', 'source_url': None, 'wiki_query': None, 'logging_time': '2024-12-27 11:31:00 UTC'}
2024-12-27 19:31:00,641 - File Failed in extraction: {'message': 'Failed To Process File:book.txt or LLM Unable To Parse Content ', 'error_message': 'Error while reading the file content or metadata', 'file_name': 'book.txt', 'status': 'Failed', 'db_url': 'neo4j://127.0.0.1:7687', 'failed_count': 1, 'source_type': 'local file', 'source_url': None, 'wiki_query': None, 'logging_time': '2024-12-27 11:31:00 UTC'}
Traceback (most recent call last):
File "/Users/Documents/workplace/gouwu-python/llm-graph-builder/backend/src/document_sources/local_file.py", line 38, in get_documents_from_file_by_path
unstructured_pages = loader.load()
File "/Users/miniforge3/envs/llm-graph-builder0/lib/python3.10/site-packages/langchain_core/document_loaders/base.py", line 31, in load
return list(self.lazy_load())
File "/Users/miniforge3/envs/llm-graph-builder0/lib/python3.10/site-packages/langchain_community/document_loaders/unstructured.py", line 107, in lazy_load
elements = self._get_elements()
File "/Users/miniforge3/envs/llm-graph-builder0/lib/python3.10/site-packages/langchain_community/document_loaders/unstructured.py", line 228, in _get_elements
return partition(filename=self.file_path, **self.unstructured_kwargs)
File "/Users/miniforge3/envs/llm-graph-builder0/lib/python3.10/site-packages/unstructured/partition/auto.py", line 181, in partition
file_type = detect_filetype(
File "/Users/miniforge3/envs/llm-graph-builder0/lib/python3.10/site-packages/unstructured/file_utils/filetype.py", line 98, in detect_filetype
return _FileTypeDetector.file_type(ctx)
File "/Users/miniforge3/envs/llm-graph-builder0/lib/python3.10/site-packages/unstructured/file_utils/filetype.py", line 131, in file_type
return cls(ctx)._file_type
File "/Users/miniforge3/envs/llm-graph-builder0/lib/python3.10/site-packages/unstructured/file_utils/filetype.py", line 141, in _file_type
if file_type := self._file_type_from_guessed_mime_type:
File "/Users/miniforge3/envs/llm-graph-builder0/lib/python3.10/site-packages/unstructured/file_utils/filetype.py", line 181, in _file_type_from_guessed_mime_type
mime_type = self._ctx.mime_type
File "/Users/miniforge3/envs/llm-graph-builder0/lib/python3.10/site-packages/unstructured/utils.py", line 154, in get
value = self._fget(obj)
File "/Users/miniforge3/envs/llm-graph-builder0/lib/python3.10/site-packages/unstructured/file_utils/filetype.py", line 362, in mime_type
import magic
File "/Users/miniforge3/envs/llm-graph-builder0/lib/python3.10/site-packages/magic/init.py", line 209, in
libmagic = loader.load_lib()
File "/Users/miniforge3/envs/llm-graph-builder0/lib/python3.10/site-packages/magic/loader.py", line 49, in load_lib
raise ImportError('failed to find libmagic. Check your installation')
ImportError: failed to find libmagic. Check your installation

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/Users/Documents/workplace/gouwu-python/llm-graph-builder/backend/score.py", line 209, in extract_knowledge_graph_from_file
uri_latency, result = await extract_graph_from_file_local_file(uri, userName, password, database, model, merged_file_path, file_name, allowedNodes, allowedRelationship, retry_condition)
File "/Users/Documents/workplace/gouwu-python/llm-graph-builder/backend/src/main.py", line 227, in extract_graph_from_file_local_file
file_name, pages, file_extension = get_documents_from_file_by_path(merged_file_path,fileName)
File "/Users/Documents/workplace/gouwu-python/llm-graph-builder/backend/src/document_sources/local_file.py", line 41, in get_documents_from_file_by_path
raise Exception('Error while reading the file content or metadata')
Exception: Error while reading the file content or metadata
INFO: 127.0.0.1:58037 - "POST /extract HTTP/1.1" 200 OK
INFO: 127.0.0.1:58040 - "GET /update_extract_status/book.txt?url=neo4j://127.0.0.1:7687&userName=neo4j&password=bW9uYXJjaC1zdG9jay1leHBsb3JlLWZsdXRlLXRleGFzLTc3NDI=&database=neo4j HTTP/1.1" 200 OK
2024-12-27 19:31:01,121 - Exception in post_processing tasks: local variable 'api_name' referenced before assignment
Traceback (most recent call last):
File "/Users/Documents/workplace/gouwu-python/llm-graph-builder/backend/score.py", line 347, in post_processing
json_obj = {'api_name': api_name, 'db_url': uri, 'userName':userName, 'database':database, 'tasks':tasks, 'logging_time': formatted_time(datetime.now(timezone.utc)), 'elapsed_api_time':f'{elapsed_time:.2f}'}
UnboundLocalError: local variable 'api_name' referenced before assignment
INFO: 127.0.0.1:58037 - "POST /post_processing HTTP/1.1" 200 OK
2024-12-27 19:31:01,298 - SSE Client disconnected

@NAMEs
Copy link
Author

NAMEs commented Dec 30, 2024

Same mistake. Did you fix it?

@kaustubh-darekar
Copy link
Collaborator

We have added sudo apt-get install libmagic1 command in dockerfile. https://github.com/neo4j-labs/llm-graph-builder/blob/main/backend/Dockerfile
Try running dockerfile once.

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