我在PyCharm中的Fitz库中遇到导入错误

ht4b089n  于 8个月前  发布在  PyCharm
关注(0)|答案(2)|浏览(153)

我遇到了在PyCharm中导入Fitz库的问题。我安装了PyMuPDF,并在我的代码中添加了“import fitz”,但它给了我这个错误:

ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/fitz/_fitz.so, 0x0002): tried: '/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/fitz/_fitz.so' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64')), '/System/Volumes/Preboot/Cryptexes/OS/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/fitz/_fitz.so' (no such file), '/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/fitz/_fitz.so' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64'))

如何修复此错误?

6ss1mwsb

6ss1mwsb1#

您似乎正在使用M1-MacBook,因此出现此错误(mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64'))。直接为“x86_64”架构执行pip install PyMuPDF构建。您需要通过以下方式直接从源版本构建PyMuPDF

  • 首先安装mupdfswigfreetype
brew install mupdf swig freetype
  • 然后从源代码安装:
pip install https://github.com/pymupdf/PyMuPDF/archive/master.tar.gz

你可以从这里了解更多:

xesrikrc

xesrikrc2#

问题是这个不能在我的mac mini m2芯片上工作,因为没有任何轮子支持它,但有一个新的轮子。如果你有同样的问题,在你的终端上使用这个。

pip install --upgrade pymupdf

相关问题