pymupdf / RAG

RAG (Retrieval-Augmented Generation) Chatbot Examples Using PyMuPDF
https://pymupdf.readthedocs.io/en/latest/pymupdf4llm
GNU Affero General Public License v3.0
518 stars 81 forks source link

AttributeError: partially initialized module 'pymupdf4llm' has no attribute 'to_markdown' (most likely due to a circular import) #169

Closed majestichou closed 1 week ago

majestichou commented 1 month ago

My code is as follows:

import pymupdf4llm
import pathlib

md_text = pymupdf4llm.to_markdown("R1-2403963.pdf")

pathlib.Path("output.md").write_bytes(md_text.encode())

The package list is as follows:

# packages in environment at D:\anaconda\envs\pymupdf4llm:
#
# Name                    Version                   Build  Channel
bzip2                     1.0.8                h2bbff1b_6    defaults
ca-certificates           2024.9.24            haa95532_0    defaults
libffi                    3.4.4                hd77b12b_1    defaults
openssl                   1.1.1w               h2bbff1b_0    defaults
pip                       24.2            py310haa95532_0    defaults
pymupdf                   1.24.11                  pypi_0    pypi
pymupdf4llm               0.0.17                   pypi_0    pypi
python                    3.10.0               h96c0403_3    defaults
setuptools                75.1.0          py310haa95532_0    defaults
sqlite                    3.45.3               h2bbff1b_0    defaults
tk                        8.6.14               h0416ee5_0    defaults
tzdata                    2024b                h04d1e81_0    defaults
vc                        14.40                h2eaa2aa_1    defaults
vs2015_runtime            14.40.33807          h98bb1dd_1    defaults
wheel                     0.44.0          py310haa95532_0    defaults
xz                        5.4.6                h8cc25b3_1    defaults
zlib                      1.2.13               h8cc25b3_1    defaults
JorjMcKie commented 1 month ago

Cannot reproduce - works on Linux and Windows with this configuration for me. Try to uninstall pymupdf4llm via PIP and install it again.

majestichou commented 1 month ago

Try to uninstall pymupdf4llm via PIP and install it again

what's your version of pip?

JorjMcKie commented 1 month ago

I am taking no risks here: I always use the latest version.