ERROR: Could not build wheels for PyMuPDF, which is required to install pyproject.toml-based project

文章关注在迁移过程中遇到的PyMuPDF安装难题,特别提及了与swig相关的编译失败,并提供了Windows环境下可能的解决方案。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

日常问题排查


今天在迁移开发环境时碰到一个问题,报错信息如下

      PyMuPDF/setup.py: libraries=['mupdf', 'mupdf-third']
      PyMuPDF/setup.py: include_dirs=['mupdf-1.20.0-source/include', 'mupdf-1.20.0-source/include/mupdf', 'mupdf-1.20.0-source/thirdparty/freetype/include', '/usr/include/freetype2', '/usr/local/include/freetype2', '/usr/X11R6/include/freetype2', '/opt/homebrew/include', '/opt/homebrew/include/freetype2']
      PyMuPDF/setup.py: extra_link_args=[]
      running bdist_wheel
      running build
      running build_py
      running build_ext
      building 'fitz._fitz' extension
      swigging fitz/fitz.i to fitz/fitz_wrap.c
      swig -python -o fitz/fitz_wrap.c fitz/fitz.i
      error: command 'swig' failed: No such file or directory
      [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

尝试着变换PyMuPDF的版本,发现部分版本的安装没问题,但是项目指定的版本1.20.2始终报错。

**

error: command ‘swig’ failed

** 怀疑时swig的问题
执行brew install swig

brew install swig

再次安装成功,如果是windows,对应安装对应的swig.exe,如果还是找不到,则可能是环境变量未添加
在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值