使用 pip 安装 paddleocr 时如何修复“PyMuPDF 中的错误”?

Jin*_*ore 7 pip pymupdf paddleocr

在做时pip install paddleocr,我在为 PyMuPDF 构建轮子时遇到错误。

\n
Building wheels for collected packages: PyMuPDF\nBuilding wheel for PyMuPDF (setup.py) ... error\nerror: subprocess-exited-with-error\n\n  \xc3\x97 python setup.py bdist_wheel did not run successfully.\n  \xe2\x94\x82 exit code: 1\n  \xe2\x95\xb0\xe2\x94\x80> [70 lines of output]\n\n\n\nTraceback (most recent call last):\n        File "<string>", line 2, in <module>\n        File "<pip-setuptools-caller>", line 34, in <module>\n        File "C:\\Users\\3551\\AppData\\Local\\Temp\\pip-install-ip72hta1\\pymupdf_f7a2c6bc313a492fa6c66ad0817a4616\\setup.py", line 487, in <module>\n          mupdf_local = get_mupdf()\n                        ^^^^^^^^^^^\n        File "C:\\Users\\3551\\AppData\\Local\\Temp\\pip-install-ip72hta1\\pymupdf_f7a2c6bc313a492fa6c66ad0817a4616\\setup.py", line 450, in get_mupdf\n          return tar_extract( mupdf_tgz, exists='return')\n                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n        File "C:\\Users\\3551\\AppData\\Local\\Temp\\pip-install-ip72hta1\\pymupdf_f7a2c6bc313a492fa6c66ad0817a4616\\setup.py", line 183, in tar_extract\n          t.extractall()\n        File "C:\\Users\\3551\\AppData\\Local\\Programs\\Python\\Python311\\Lib\\tarfile.py", line 2059, in extractall\n          self.extract(tarinfo, path, set_attrs=not tarinfo.isdir(),\n        File "C:\\Users\\3551\\AppData\\Local\\Programs\\Python\\Python311\\Lib\\tarfile.py", line 2100, in extract\n          self._extract_member(tarinfo, os.path.join(path, tarinfo.name),\n        File "C:\\Users\\3551\\AppData\\Local\\Programs\\Python\\Python311\\Lib\\tarfile.py", line 2173, in _extract_member\n          self.makefile(tarinfo, targetpath)\n        File "C:\\Users\\3551\\AppData\\Local\\Programs\\Python\\Python311\\Lib\\tarfile.py", line 2214, in makefile\n          with bltn_open(targetpath, "wb") as target:\n               ^^^^^^^^^^^^^^^^^^^^^^^^^^^\n      FileNotFoundError: [Errno 2] No such file or directory: '.\\\\mupdf-1.20.3-source\\\\thirdparty\\\\harfbuzz\\\\test\\\\shaping\\\\texts\\\\in-house\\\\shaper-indic\\\\script-devanagari\\\\utrrs\\\\codepoint\\\\IndicFontFeatureCodepoint-AdditionalConsonants.txt'\n      [end of output]\n\n  note: This error originates from a subprocess, and is likely not a problem with pip.\n  ERROR: Failed building wheel for PyMuPDF\n  Running setup.py clean for PyMuPDF\nFailed to build PyMuPDF\nERROR: Could not build wheels for PyMuPDF, which is required to install pyproject.toml-based projects\n
Run Code Online (Sandbox Code Playgroud)\n

我尝试pip install wheel使用 pip 安装 PyMuPDF,pip install PyMuPDF然后安装 paddleocr,pip install paddleocr但同样的问题是为 PyMuPDF 构建轮文件时出错。

\n

我正在使用intel i3, 64位处理器\n并且 python 版本是3.11.3

\n

小智 10

试试这个 pip install "paddleocr>=2.0.1" --upgrade PyMuPDF==1.21.1 它对我有用。


Fly*_*ler 7

paddleocr具有要求PyMuPDF<1.21.0并且PyMuPDF==1.20.2(符合 paddleocr 要求的最新版本)仅具有 python 3.10 之前的 whl 文件。因此,pip退回到尝试从源安装。

确切的错误消息来自PyMuPDF尝试下载其依赖项之一的安装脚本,该脚本在提取文件期间失败.tar.gz。您现在有不同的选择:

  1. 手动下载https://mupdf.com/downloads/archive/mupdf-1.20.3-source.tar.gz,然后将存档解压到您选择的路径。将环境变量设置PYMUPDF_SETUP_MUPDF_BUILD为解压文件夹的路径mupdf-1.20.3并尝试运行pip install PyMuPDF==1.20.2。请注意,您还需要一个可以使用此方法的编译器

  2. 下载此非官方 whl 文件:https://drive.google.com/drive/folders/1PESjDkovpvnrWFTKji4-qgT3rcVz-oF ?usp=sharing 并安装它pip install <path to the whl file>