如何在使用pip安装paddleocr时修复’Error in PyMuPDF’错误?

huangapple go评论168阅读模式
英文:

How can I fix the 'Error in PyMuPDF' when installing paddleocr with pip?

问题

在执行pip install paddleocr时,我遇到了在构建PyMuPDF的wheel时出现错误的问题。

错误信息如下:

构建PyMuPDF收集的包的wheel时出错:PyMuPDF
构建PyMuPDF (setup.py)的wheel时出错... 错误
错误:子进程以错误退出

× python setup.py bdist_wheel未成功运行。
│ 退出代码:1
╰─> [70行输出]


Traceback (most recent call last):
        File "<string>", line 2, in <module>
        File "<pip-setuptools-caller>", line 34, in <module>
        File "C:\Users51\AppData\Local\Temp\pip-install-ip72hta1\pymupdf_f7a2c6bc313a492fa6c66ad0817a4616\setup.py", line 487, in <module>
          mupdf_local = get_mupdf()
                        ^^^^^^^^^^^
        File "C:\Users51\AppData\Local\Temp\pip-install-ip72hta1\pymupdf_f7a2c6bc313a492fa6c66ad0817a4616\setup.py", line 450, in get_mupdf
          return tar_extract( mupdf_tgz, exists='return')
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "C:\Users51\AppData\Local\Temp\pip-install-ip72hta1\pymupdf_f7a2c6bc313a492fa6c66ad0817a4616\setup.py", line 183, in tar_extract
          t.extractall()
        File "C:\Users51\AppData\Local\Programs\Python\Python311\Lib\tarfile.py", line 2059, in extractall
          self.extract(tarinfo, path, set_attrs=not tarinfo.isdir(),
        File "C:\Users51\AppData\Local\Programs\Python\Python311\Lib\tarfile.py", line 2100, in extract
          self._extract_member(tarinfo, os.path.join(path, tarinfo.name),
        File "C:\Users51\AppData\Local\Programs\Python\Python311\Lib\tarfile.py", line 2173, in _extract_member
          self.makefile(tarinfo, targetpath)
        File "C:\Users51\AppData\Local\Programs\Python\Python311\Lib\tarfile.py", line 2214, in makefile
          with bltn_open(targetpath, "wb") as target:
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^
      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'
      [output结束]

注意:此错误源自子进程,可能与pip无关。
ERROR: Failed building wheel for PyMuPDF
Running setup.py clean for PyMuPDF
Failed to build PyMuPDF
ERROR: Could not build wheels for PyMuPDF, which is required to install pyproject.toml-based projects

我尝试了使用pip install wheel和使用pip install PyMuPDF来安装PyMuPDF,然后再使用pip install paddleocr来安装paddleocr,但是同样的问题仍然存在,即无法构建PyMuPDF的wheel文件。

我使用的是intel i3处理器,64位版本,Python版本是3.11.3

英文:

When doing pip install paddleocr, I am facing an error in building wheel for PyMuPDF.

Building wheels for collected packages: PyMuPDF
Building wheel for PyMuPDF (setup.py) ... error
error: subprocess-exited-with-error

  &#215; python setup.py bdist_wheel did not run successfully.
  │ exit code: 1
  ╰─&gt; [70 lines of output]



Traceback (most recent call last):
        File &quot;&lt;string&gt;&quot;, line 2, in &lt;module&gt;
        File &quot;&lt;pip-setuptools-caller&gt;&quot;, line 34, in &lt;module&gt;
        File &quot;C:\Users51\AppData\Local\Temp\pip-install-ip72hta1\pymupdf_f7a2c6bc313a492fa6c66ad0817a4616\setup.py&quot;, line 487, in &lt;module&gt;
          mupdf_local = get_mupdf()
                        ^^^^^^^^^^^
        File &quot;C:\Users51\AppData\Local\Temp\pip-install-ip72hta1\pymupdf_f7a2c6bc313a492fa6c66ad0817a4616\setup.py&quot;, line 450, in get_mupdf
          return tar_extract( mupdf_tgz, exists=&#39;return&#39;)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File &quot;C:\Users51\AppData\Local\Temp\pip-install-ip72hta1\pymupdf_f7a2c6bc313a492fa6c66ad0817a4616\setup.py&quot;, line 183, in tar_extract
          t.extractall()
        File &quot;C:\Users51\AppData\Local\Programs\Python\Python311\Lib\tarfile.py&quot;, line 2059, in extractall
          self.extract(tarinfo, path, set_attrs=not tarinfo.isdir(),
        File &quot;C:\Users51\AppData\Local\Programs\Python\Python311\Lib\tarfile.py&quot;, line 2100, in extract
          self._extract_member(tarinfo, os.path.join(path, tarinfo.name),
        File &quot;C:\Users51\AppData\Local\Programs\Python\Python311\Lib\tarfile.py&quot;, line 2173, in _extract_member
          self.makefile(tarinfo, targetpath)
        File &quot;C:\Users51\AppData\Local\Programs\Python\Python311\Lib\tarfile.py&quot;, line 2214, in makefile
          with bltn_open(targetpath, &quot;wb&quot;) as target:
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^
      FileNotFoundError: [Errno 2] No such file or directory: &#39;.\\mupdf-1.20.3-source\\thirdparty\\harfbuzz\\test\\shaping\\texts\\in-house\\shaper-indic\\script-devanagari\\utrrs\\codepoint\\IndicFontFeatureCodepoint-AdditionalConsonants.txt&#39;
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for PyMuPDF
  Running setup.py clean for PyMuPDF
Failed to build PyMuPDF
ERROR: Could not build wheels for PyMuPDF, which is required to install pyproject.toml-based projects

I tried doing pip install wheel and installing the PyMuPDF using pip by pip install PyMuPDF then install paddleocr by pip install paddleocr but the same problem is there error building wheel file for PyMuPDF.

I am using a intel i3, 64 bit processor
and python version is 3.11.3

答案1

得分: 3

paddleocrPyMuPDF&lt;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-o-F?usp=sharing ,然后使用 pip install &lt;whl文件的路径&gt; 进行安装。

英文:

paddleocr has the requirement PyMuPDF&lt;1.21.0 and PyMuPDF==1.20.2 (the latest version that fits the paddleocr requirement) only has whl files up to python 3.10. Therefor, pip falls back to trying to install from source.

The exact error message is from the install script of PyMuPDF trying to download one of its dependencies, which fails during extraction of the .tar.gz file. You have different options now:

  1. Manually download https://mupdf.com/downloads/archive/mupdf-1.20.3-source.tar.gz then extract the archive to a path of your choosing. Set the environment variable PYMUPDF_SETUP_MUPDF_BUILD to the path of the extracted mupdf-1.20.3 folder and try to run pip install PyMuPDF==1.20.2. Note that you will also need a working compiler for this approach

  2. Download this unofficial whl file: https://drive.google.com/drive/folders/1PESjDkovpvnrWFTKji4-qgT3rcVz-o-F?usp=sharing and install it with pip install &lt;path to the whl file&gt;

答案2

得分: 3

尝试这个

pip install "paddleocr>=2.0.1" --upgrade PyMuPDF==1.21.1

对我有效。

英文:

Try this one
pip install "paddleocr>=2.0.1" --upgrade PyMuPDF==1.21.1
it works for me.

答案3

得分: 0

对于在 macOS 上遇到此问题的开发者,您需要安装 pip install PyMuPDF==1.20.0,因为 PaddleOCR 需要 PyMuPDF&lt;1.21.0

如果您仍然遇到 ERROR: Failed building wheel for PyMuPDF 问题,请首先尝试 brew install swig,然后再尝试 pip install PyMuPDF==1.20.0,它将起作用。

英文:

For the developers who are facing this issue on macOS, you need to install pip install PyMuPDF==1.20.0 as PaddleOCR requires PyMuPDF&lt;1.21.0.

If you are still facing the ERROR: Failed building wheel for PyMuPDF issue then try brew install swig first and then try pip install PyMuPDF==1.20.0 and it will work.

huangapple
  • 本文由 发表于 2023年6月1日 14:43:07
  • 转载请务必保留本文链接:https://go.coder-hub.com/76379293.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定