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

PyPortfolioOpt安装失败求助:编译qdldl时缺失CMake

PyPortfolioOpt安装失败:CMake缺失导致qdldl编译错误

问题描述

尝试安装PyPortfolioOpt时失败,已升级pip但仍报错,核心问题为编译依赖包qdldl时系统未找到CMake工具,安装流程中断。关键错误片段如下:

FileNotFoundError: [Errno 2] No such file or directory: 'cmake'
RuntimeError: CMake must be installed to build qdldl

完整错误输出:

Installing build dependencies ... error
error: subprocess-exited-with-error

× pip subprocess to install build dependencies did not run successfully.
│ exit code: 1
╰─> [119 lines of output]
Collecting oldest-supported-numpy
Using cached oldest_supported_numpy-2023.12.21-py3-none-any.whl.metadata (9.8 kB)
...(省略中间冗余日志)
Building wheel for qdldl (pyproject.toml): finished with status 'error'
error: subprocess-exited-with-error

× Building wheel for qdldl (pyproject.toml) did not run successfully.
│ exit code: 1
╰─> [72 lines of output]
    running bdist_wheel
    running build
    running build_ext
    Traceback (most recent call last):
      File "<string>", line 81, in build_extensions
      File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/subprocess.py", line 466, in check_output
        return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/subprocess.py", line 548, in run
        with Popen(*popenargs, **kwargs) as process:
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/subprocess.py", line 1024, in __init__
        self._execute_child(args, executable, preexec_fn, close_fds,
      File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/subprocess.py", line 1917, in _execute_child
        raise child_exception_type(errno_num, err_msg, err_filename)
    FileNotFoundError: [Errno 2] No such file or directory: 'cmake'

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
      ...(省略中间栈追踪信息)
      File "<string>", line 83, in build_extensions
    RuntimeError: CMake must be installed to build qdldl
    [end of output]

note: This error originates from a subprocess, and is likely not a problem with pip.
ERROR: Failed building wheel for qdldl

Failed to build qdldl
ERROR: Could not build wheels for qdldl, which is required to install pyproject.toml-based projects
[end of output]

note: This error originates from a subprocess, and is likely not a problem with pip.

解决步骤

  • 安装CMake工具:根据操作系统选择对应方式
    • macOS:使用Homebrew安装
      brew install cmake
      
    • Linux(Debian/Ubuntu):使用apt安装
      sudo apt update && sudo apt install cmake
      
    • Windows:下载CMake安装包完成安装后,将CMake的bin目录添加到系统环境变量PATH中
  • 验证CMake安装:在终端/命令行执行以下命令,确认输出版本信息
    cmake --version
    
  • 重新安装PyPortfolioOpt:执行安装命令
    pip install pyportfolioopt
    

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.02 01:51:02