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

使用pip/pip3安装fb-re2包失败,编译报错缺少re2头文件

安装fb-re2 Python包时遇到编译错误求助

执行sudo pip3 install fb-re2时出现以下错误:

# sudo pip3 install fb-re2
Collecting fb-re2
  Using cached fb-re2-1.0.7.tar.gz (9.4 kB)
  Preparing metadata (setup.py) ... done
Building wheels for collected packages: fb-re2
  Building wheel for fb-re2 (setup.py) ... error
  error: subprocess-exited-with-error
  
  × python setup.py bdist_wheel did not run successfully.
  │ exit code: 1
  ╰─> [15 lines of output]
      running bdist_wheel
      running build
      running build_py
      creating build
      creating build/lib.linux-x86_64-cpython-310
      copying re2.py -> build/lib.linux-x86_64-cpython-310
      running build_ext
      building '_re2' extension
      creating build/temp.linux-x86_64-cpython-310
      x86_64-linux-gnu-gcc -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -fPIC -I/usr/include/python3.10 -c _re2.cc -o build/temp.linux-x86_64-cpython-310/_re2.o -std=c++11
      _re2.cc:37:10: fatal error: re2/re2.h: No such file or directory
         37 | #include <re2/re2.h>
            |          ^~~~~~~~~~~
      compilation terminated.
      error: command '/usr/bin/x86_64-linux-gnu-gcc' failed with exit code 1
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for fb-re2
  Running setup.py clean for fb-re2
Failed to build fb-re2
ERROR: Could not build wheels for fb-re2, which is required to install pyproject.toml-based projects

已尝试以下步骤但均未解决:

65  pip install wheel setuptools pip --upgrade
   66  pip3 install wheel setuptools pip --upgrade
   67  sudo pip3 install .
   68  pip3 install wheel
   69  pip install fb-re2 --no-cache-dir
   70  pip3 install fb-re2 --no-cache-dir
   71  pip install wheel
   72  apt install fb-re2
   73  apt update -y
   74  pip install localpip
   75  localpip install fb-re2
   76  sudo pip3 install fb-re2  --no-binary :all:
   77  sudo apt-get install build-essential libssl-dev libffi-dev python-dev
   78  pip install -U pip setuptools
   79  sudo pip3 install fb-re2
解决方案

错误核心是编译时找不到re2/re2.h头文件,说明系统缺少RE2的开发库。针对Debian/Ubuntu系列系统,执行以下命令安装依赖:

sudo apt update && sudo apt install libre2-dev

安装完成后,再重新执行:

sudo pip3 install fb-re2

内容的提问来源于stack exchange,提问作者Anoop Jose

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.20 10:50:24