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

安装Python包youtube2zim时提示libzim库未找到的问题求助

解决youtube2zim安装时libzim依赖找不到的问题

系统环境

  • M2 MacBook Air
  • MacOS Ventura 13.4.1 (c)
  • 通过HomeBrew安装Python(python@3.11)和virtualenv
  • 使用zsh shell

问题重现

目标安装Python包youtube2zim,按照官方Virtualenv章节步骤操作:

virtualenv -p python3 ./ # 创建虚拟环境
source bin/activate      # 激活虚拟环境
pip3 install youtube2zim # 安装依赖
youtube2zim --help       # 查看帮助

执行pip3 install youtube2zim时安装中断,报错信息如下:

Collecting libzim<1.2,>=1.1.0 (from zimscraperlib<1.9,>=1.8.0->youtube2zim)
  Using cached libzim-1.1.0.tar.gz (8.3 MB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... error
  error: subprocess-exited-with-error
  
  × Preparing metadata (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [2 lines of output]
      [!] The libzim library cannot be found.
      Please verify it is correctly installed and can be found.
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed

× Encountered error while generating package metadata.
╰─> See above for output.

note: This is an issue with the package mentioned above, not pip.
hint: See above for details.

解决方案

youtube2zim依赖的libzim是底层C库,pip安装Python绑定前需要本地已安装该库,具体步骤:

  1. 用Homebrew安装libzim
    终端执行:

    brew install libzim
    

    该命令会将兼容版本的libzim库安装到系统中。

  2. 让虚拟环境识别libzim路径
    激活虚拟环境后,设置环境变量确保pip能找到libzim,再执行安装:

    source bin/activate
    export PKG_CONFIG_PATH="/opt/homebrew/lib/pkgconfig:$PKG_CONFIG_PATH"
    pip3 install youtube2zim
    
  3. 验证安装结果
    安装完成后执行:

    youtube2zim --help
    

    若正常显示帮助信息,说明安装成功。

备用方案

如果上述步骤仍报错,可直接指定libzim的头文件和库路径:

source bin/activate
export CFLAGS="-I/opt/homebrew/include"
export LDFLAGS="-L/opt/homebrew/lib"
pip3 install youtube2zim

内容的提问来源于stack exchange,提问作者Signor Pizza

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.11 23:53:20