SConscript 环境错误:没有名为 compiler_db 的模块

问题描述

我正在尝试编译 GitHub 项目:https://github.com/commaai/openpilot,我在创建 SCons 环境时遇到错误(对 Environment() 的调用),它指向这一行:

Environement(
# Other options ...
tools=["default","cython","compilation_db"
)

scons 的结果是:

scons: Reading sconscript files ...
EnvironmentError: No module named compilation_db:
  File "/home/skoumad/openpilot/master/SConstruct",line 213:
    "compilation_db"
  File "/usr/lib/scons/SCons/Environment.py",line 982:
    apply_tools(self,tools,toolpath)
  File "/usr/lib/scons/SCons/Environment.py",line 107:
    env.Tool(tool)
  File "/usr/lib/scons/SCons/Environment.py",line 1788:
    tool = SCons.Tool.Tool(tool,toolpath,**kw)
  File "/usr/lib/scons/SCons/Tool/__init__.py",line 118:
    module = self._tool_module()
  File "/usr/lib/scons/SCons/Tool/__init__.py",line 215:
    raise SCons.Errors.EnvironmentError(error_string)

我尝试使用以下命令安装compile_db:https://pypi.org/project/scons-compiledb/0.4.7/ 但仍然是同样的错误:/。

知道如何安装这个缺失的模块吗??

问候。

解决方法

您的 SCons 版本可能早于 4.0.0

compilation_db 工具已在 4.0.0 中添加

release notice

如果你的发行版(linux、python、macports 等)没有 4.0.0 或更高版本,那么我建议设置一个 python virtualenv(不,这不是虚拟机,它是只是一个创建干净的python环境来安装包的工具)

这是如何做到的:

# assuming posix system,for win32,of course change the path to windows correct syntax
# also the python below should be 3.5 or newer,generally it's best to use the newest installed
python -m venv ~/sconsvenv 
. ~/sconsvenv/bin/activate
pip install  scons

scons --version

# should yield

SCons by Steven Knight et al.:
    SCons: v4.1.0.post1.dc58c175da659d6c0bb3e049ba56fb42e77546cd,2021-01-20 04:32:28,by bdbaddog on ProDog2020
    SCons path: ['/Users/bdbaddog/sconsvenv/lib/python3.8/site-packages/SCons']
Copyright (c) 2001 - 2021 The SCons Foundation