You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

MacOS Conda环境安装bob.ip.gabor因bob.extension版本报错求助

bob.ip.gabor安装失败问题解决指南

问题背景

在MacOS 11.6的Conda环境(Python 3.9)里执行pip install bob.ip.gabor会报错,核心矛盾:

  • bob.ip.gabor的setup.py需要从bob.extension导入Extension类,但它默认会拉取最新版bob.extension 7.0.3,而该版本已移除Extension类
  • 手动安装旧版bob.extension 6.0.0能正常导入Extension,但安装bob.ip.gabor时,pip会自动将bob.extension升级回7.0.3,导致再次报错
  • 尝试过强制锁定旧版依赖、想移除报错命令里的--ignore-installed参数,但找不到修改入口

报错日志

(base) petersv@My-MacBook-Pro ~ % pip install bob.ip.gabor
Collecting bob.ip.gabor
  Using cached bob.ip.gabor-2.0.19.zip (238 kB)
  Installing build dependencies ... error
  ERROR: Command errored out with exit status 1:
   command: /Users/petersv/opt/miniconda3/bin/python /private/var/folders/j9/19867df10yj8fqd35rvwysch0000gp/T/pip-standalone-pip-cnmnc9va/__env_pip__.zip/pip install --ignore-installed --no-user --prefix /private/var/folders/j9/19867df10yj8fqd35rvwysch0000gp/T/pip-build-env-t5q80any/overlay --no-warn-script-location --no-binary :none: --only-binary :none: -i https://pypi.org/simple -- setuptools wheel bob.extension bob.blitz bob.core bob.io.base bob.sp
       cwd: None
  Complete output (498 lines):
  Collecting setuptools
    Using cached setuptools-67.6.1-py3-none-any.whl (1.1 MB)
  Collecting wheel
    Using cached wheel-0.40.0-py3-none-any.whl (64 kB)
  Collecting bob.extension
    Using cached bob.extension-7.0.3-py3-none-any.whl
  Collecting bob.blitz
    Using cached bob.blitz-2.0.24.zip (123 kB)
    Installing build dependencies: started
    Installing build dependencies: finished with status 'done'
    Getting requirements to build wheel: started
    Getting requirements to build wheel: finished with status 'error'
    ERROR: Command errored out with exit status 1:
     command: /Users/petersv/opt/miniconda3/bin/python /var/folders/j9/19867df10yj8fqd35rvwysch0000gp/T/tmp9rvwymy8_in_process.py get_requires_for_build_wheel /var/folders/j9/19867df10yj8fqd35rvwysch0000gp/T/tmpgk7f5ocr
         cwd: /private/var/folders/j9/19867df10yj8fqd35rvwysch0000gp/T/pip-install-0nha6kd1/bob-blitz_995368b3704c4d319569fed21c27fdf2
    Complete output (15 lines):
    Traceback (most recent call last):
      File "/var/folders/j9/19867df10yj8fqd35rvwysch0000gp/T/tmp9rvwymy8_in_process.py", line 349, in <module>
        main()
      File "/var/folders/j9/19867df10yj8fqd35rvwysch0000gp/T/tmp9rvwymy8_in_process.py", line 331, in main
        json_out['return_val'] = hook(**hook_input['kwargs'])
      File "/var/folders/j9/19867df10yj8fqd35rvwysch0000gp/T/tmp9rvwymy8_in_process.py", line 117, in get_requires_for_build_wheel
        return hook(config_settings)
      File "/private/var/folders/j9/19867df10yj8fqd35rvwysch0000gp/T/pip-build-env-4uyl9cvl/overlay/lib/python3.9/site-packages/setuptools/build_meta.py", line 338, in get_requires_for_build_wheel
        return self._get_build_requires(config_settings, requirements=['wheel'])
      File "/private/var/folders/j9/19867df10yj8fqd35rvwysch0000gp/T/pip-build-env-4uyl9cvl/overlay/lib/python3.9/site-packages/setuptools/build_meta.py", line 320, in _get_build_requires
        self.run_setup()
      File "/private/var/folders/j9/19867df10yj8fqd35rvwysch0000gp/T/pip-build-env-4uyl9cvl/overlay/lib/python3.9/site-packages/setuptools/build_meta.py", line 335, in run_setup
        exec(code, locals())
      File "<string>", line 9, in <module>
    ImportError: cannot import name 'Extension' from 'bob.extension' (/private/var/folders/j9/19867df10yj8fqd35rvwysch0000gp/T/pip-build-env-4uyl9cvl/overlay/lib/python3.9/site-packages/bob/extension/__init__.py)
    ----------------------------------------

解决方案

方法1:一次性指定所有兼容版本安装

直接在pip命令里明确写出每个bob依赖的兼容版本,让pip不会自动升级:

pip install bob.extension==6.0.0 bob.blitz==2.0.23 bob.core==2.0.24 bob.io.base==2.0.30 bob.sp==2.0.25 bob.ip.gabor==2.0.19

这些版本都是和bob.extension 6.x匹配的稳定版,pip会严格按照指定版本安装,不会自作主张换成最新版。

方法2:用约束文件锁定依赖版本

  1. 新建一个constraints.txt文件,内容如下:
bob.extension==6.0.0
bob.blitz<=2.0.23
bob.core<=2.0.24
bob.io.base<=2.0.30
bob.sp<=2.0.25
  1. 执行安装命令时带上约束文件:
pip install bob.ip.gabor -c constraints.txt

约束文件会强制pip只安装指定版本范围内的依赖,避免自动升级到不兼容的新版本。

方法3:下载源码修改依赖后本地安装

  1. 先下载bob.ip.gabor的源码包(不下载依赖):
pip download bob.ip.gabor --no-deps
  1. 解压下载的zip包,进入解压后的文件夹
  2. 找到setup.py文件,修改里面的依赖声明,把bob.extension的版本限制在7.0.0以下:
    找到类似这样的代码:
    install_requires = [
        'bob.extension',
        # 其他依赖项...
    ]
    
    改成:
    install_requires = [
        'bob.extension<7.0.0',
        # 其他依赖项...
    ]
    
  3. 然后在当前目录执行本地安装:
pip install .

方法4:用conda安装(推荐,如果conda-forge有包)

如果conda-forge仓库有兼容的bob.ip.gabor包,直接用conda安装更省心,conda的依赖解析器会自动处理版本兼容问题:

conda install -c conda-forge bob.ip.gabor

内容的提问来源于stack exchange,提问作者Peter Savadjiev

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.24 20:54:59