Ubuntu环境下安装whisper-cpp-python失败,求解决方法
解决whisper-cpp-python安装失败问题
环境信息
- Ubuntu 22.04.5 LTS
- Python 3.10.12
- CMake 4.0.3
尝试的安装命令
pip install whisper-cpp-python
错误信息
Building wheels for collected packages: whisper-cpp-python
Building wheel for whisper-cpp-python (pyproject.toml) ... error
error: subprocess-exited-with-error× Building wheel for whisper-cpp-python (pyproject.toml) did not run successfully.
│ exit code: 1
╰─> [91 lines of output]-------------------------------------------------------------------------------- -- Trying 'Ninja' generator -------------------------------- --------------------------- ---------------------- ----------------- ------------ ------- -- CMake Deprecation Warning at CMakeLists.txt:1 (cmake_minimum_required): Compatibility with CMake < 3.10 will be removed from a future version of CMake. Update the VERSION argument <min> value. Or, use the <min>...<max> syntax to tell CMake that the project requires at least <min> but has been updated to work with policies introduced by <max> or earlier. Not searching for unused variables given on the command line. -- The C compiler identification is GNU 11.4.0 -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Check for working C compiler: /usr/bin/cc - skipped -- Detecting C compile features -- Detecting C compile features - done -- The CXX compiler identification is GNU 11.4.0 -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Check for working CXX compiler: /usr/bin/c++ - skipped -- Detecting CXX compile features -- Detecting C compile features - done -- Configuring done (0.4s) -- Generating done (0.0s) -- Build files have been written to: /tmp/pip-install-77w6z33k/whisper-cpp-python_a0b2df45a9ee419fb855cbd372dff6c6/_cmake_test_compile/build -- ------- ------------ ----------------- ---------------------- --------------------------- -------------------------------- -- Trying 'Ninja' generator - success -------------------------------------------------------------------------------- Configuring Project Working directory: /tmp/pip-install-77w6z33k/whisper-cpp-python_a0b2df45a9ee419fb855cbd372dff6c6/_skbuild/linux-x86_64-3.10/cmake-build Command: /tmp/pip-build-env-h5693axl/overlay/lib/python3.10/site-packages/cmake/data/bin/cmake /tmp/pip-install-77w6z33k/whisper-cpp-python_a0b2df45a9ee419fb855cbd372dff6c6 -G Ninja -DCMAKE_MAKE_PROGRAM:FILEPATH=ninja --no-warn-unused-cli -DCMAKE_INSTALL_PREFIX:PATH=/tmp/pip-install-77w6z33k/whisper-cpp-python_a0b2df45a9ee419fb855cbd372dff6c6/_skbuild/linux-x86_64-3.10/cmake-install -DPYTHON_VERSION_STRING:STRING=3.10.12 -DSKBUILD:INTERNAL=TRUE -DCMAKE_MODULE_PATH:PATH=/tmp/pip-build-env-h5693axl/overlay/lib/python3.10/site-packages/skbuild/resources/cmake -DPYTHON_EXECUTABLE:PATH=/home/amitli/python_venvs/venvWhisperCPP/bin/python3 -DPYTHON_INCLUDE_DIR:PATH=/usr/include/python3.10 -DPYTHON_LIBRARY:PATH=/usr/lib/x86_64-linux-gnu/libpython3.10.so -DPython_EXECUTABLE:PATH=/home/amitli/python_venvs/venvWhisperCPP/bin/python3 -DPython_ROOT_DIR:PATH=/home/amitli/python_venvs/venvWhisperCPP -DPython_FIND_REGISTRY:STRING=NEVER -DPython_INCLUDE_DIR:PATH=/usr/include/python3.10 -DPython3_EXECUTABLE:PATH=/home/amitli/python_venvs/venvWhisperCPP/bin/python3 -DPython3_ROOT_DIR:PATH=/home/amitli/python_venvs/venvWhisperCPP -DPython3_FIND_REGISTRY:STRING=NEVER -DPython3_INCLUDE_DIR:PATH=/usr/include/python3.10 -DCMAKE_MAKE_PROGRAM:FILEPATH=ninja -DCMAKE_BUILD_TYPE:STRING=Release Not searching for unused variables given on the command line. -- The C compiler identification is GNU 11.4.0 -- The CXX compiler identification is GNU 11.4.0 -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Check for working C compiler: /usr/bin/cc - skipped -- Detecting C compile features -- Detecting C compile features - done -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Check for working CXX compiler: /usr/bin/c++ - skipped -- Detecting CXX compile features -- Detecting C compile features - done CMake Error at vendor/whisper.cpp/CMakeLists.txt:1 (cmake_minimum_required): Compatibility with CMake < 3.5 has been removed from CMake. Update the VERSION argument <min> value. Or, use the <min>...<max> syntax to tell CMake that the project requires at least <min> but has been updated to work with policies introduced by <max> or earlier. Or, add -DCMAKE_POLICY_VERSION_MINIMUM=3.5 to try configuring anyway. -- Configuring incomplete, errors occurred! Traceback (most recent call last): File "/tmp/pip-build-env-h5693axl/overlay/lib/python3.10/site-packages/skbuild/setuptools_wrap.py", line 660, in setup env = cmkr.configure( File "/tmp/pip-build-env-h5693axl/overlay/lib/python3.10/site-packages/skbuild/cmaker.py", line 354, in configure raise SKBuildError(msg) An error occurred while configuring with CMake. Command: /tmp/pip-build-env-h5693axl/overlay/lib/python3.10/site-packages/cmake/data/bin/cmake /tmp/pip-install-77w6z33k/whisper-cpp-python_a0b2df45a9ee419fb855cbd372dff6c6 -G Ninja -DCMAKE_MAKE_PROGRAM:FILEPATH=ninja --no-warn-unused-cli -DCMAKE_INSTALL_PREFIX:PATH=/tmp/pip-install-77w6z33k/whisper-cpp-python_a0b2df45a9ee419fb855cbd372dff6c6/_skbuild/linux-x86_64-3.10/cmake-install -DPYTHON_VERSION_STRING:STRING=3.10.12 -DSKBUILD:INTERNAL=TRUE -DCMAKE_MODULE_PATH:PATH=/tmp/pip-build-env-h5693axl/overlay/lib/python3.10/site-packages/skbuild/resources/cmake -DPYTHON_EXECUTABLE:PATH=/home/amitli/python_venvs/venvWhisperCPP/bin/python3 -DPYTHON_INCLUDE_DIR:PATH=/usr/include/python3.10 -DPYTHON_LIBRARY:PATH=/usr/lib/x86_64-linux-gnu/libpython3.10.so -DPython_EXECUTABLE:PATH=/home/amitli/python_venvs/venvWhisperCPP/bin/python3 -DPython_ROOT_DIR:PATH=/home/amitli/python_venvs/venvWhisperCPP -DPython_FIND_REGISTRY:STRING=NEVER -DPython_INCLUDE_DIR:PATH=/usr/include/python3.10 -DPython3_EXECUTABLE:PATH=/home/amitli/python_venvs/venvWhisperCPP/bin/python3 -DPython3_ROOT_DIR:PATH=/home/amitli/python_venvs/venvWhisperCPP -DPython3_FIND_REGISTRY:STRING=NEVER -DPython3_INCLUDE_DIR:PATH=/usr/include/python3.10 -DCMAKE_MAKE_PROGRAM:FILEPATH=ninja -DCMAKE_BUILD_TYPE:STRING=Release Source directory: /tmp/pip-install-77w6z33k/whisper-cpp-python_a0b2df45a9ee419fb855cbd372dff6c6 Working directory: /tmp/pip-install-77w6z33k/whisper-cpp-python_a0b2df45a9ee419fb855cbd372dff6c6/_skbuild/linux-x86_64-3.10/cmake-build Please see CMake's output for more information. [end of output]note: This error originates from a subprocess, and is likely not a problem with pip.
解决方法
错误核心是whisper.cpp依赖的CMake版本兼容问题,以下是三种可行方案:
方案1:传递CMake兼容参数
安装时通过环境变量指定CMAKE_POLICY_VERSION_MINIMUM,强制CMake启用旧版本兼容策略:
CMAKE_ARGS="-DCMAKE_POLICY_VERSION_MINIMUM=3.5" pip install whisper-cpp-python
方案2:降级CMake版本
如果方案1无效,将CMake降级到3.26或更早版本(该版本仍保留对旧策略的支持):
- 卸载当前CMake:
sudo apt remove --purge cmake
- 下载并安装指定版本(以3.26.4为例):
wget https://github.com/Kitware/CMake/releases/download/v3.26.4/cmake-3.26.4-linux-x86_64.tar.gz tar -xzf cmake-3.26.4-linux-x86_64.tar.gz sudo cp -r cmake-3.26.4-linux-x86_64/* /usr/local/
- 验证版本:
cmake --version
- 重新执行安装命令:
pip install whisper-cpp-python
方案3:使用预编译包
不想处理编译问题的话,可以直接安装对应平台的预编译wheel包:
pip install wheel # 替换为匹配你Python版本和系统架构的wheel包,示例: # pip install whisper_cpp_python-0.2.6-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
内容的提问来源于stack exchange,提问作者user3668129
相关产品推荐
相关产品推荐

