pythoninstallationcvxpy

Issues Installing CVXPY with pip


I'm trying to install cvxpy using pip install but am running into an error when preparing the metadata. My current Python version is 3.13.0, and I am on Windows 11. Note that I do not have Conda.

Below is the error I encounter:

C:\Users\devap>pip install cvxpy
Collecting cvxpy
  Using cached cvxpy-1.6.0-cp313-cp313-win_amd64.whl.metadata (9.4 kB)
Collecting osqp>=0.6.2 (from cvxpy)
  Using cached osqp-0.6.7.post3-cp313-cp313-win_amd64.whl.metadata (2.0 kB)
Collecting clarabel>=0.5.0 (from cvxpy)
  Using cached clarabel-0.9.0-cp37-abi3-win_amd64.whl.metadata (4.8 kB)
Collecting scs>=3.2.4.post1 (from cvxpy)
  Using cached scs-3.2.7.tar.gz (1.6 MB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Installing backend dependencies ... done
  Preparing metadata (pyproject.toml) ... error
  error: subprocess-exited-with-error

  × Preparing metadata (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [31 lines of output]
      + meson setup C:\Users\devap\AppData\Local\Temp\pip-install-93vr0jcn\scs_5d6757b4a018456a9eafc172d72fa671 C:\Users\devap\AppData\Local\Temp\pip-install-93vr0jcn\scs_5d6757b4a018456a9eafc172d72fa671\.mesonpy-uwreejb1 -Dbuildtype=release -Db_ndebug=if-release -Db_vscrt=md --native-file=C:\Users\devap\AppData\Local\Temp\pip-install-93vr0jcn\scs_5d6757b4a018456a9eafc172d72fa671\.mesonpy-uwreejb1\meson-python-native-file.ini
      The Meson build system
      Version: 1.6.0
      Source dir: C:\Users\devap\AppData\Local\Temp\pip-install-93vr0jcn\scs_5d6757b4a018456a9eafc172d72fa671
      Build dir: C:\Users\devap\AppData\Local\Temp\pip-install-93vr0jcn\scs_5d6757b4a018456a9eafc172d72fa671\.mesonpy-uwreejb1
      Build type: native build
      WARNING: Project does not target a minimum version but uses feature introduced in '1.1': meson.options file. Use meson_options.txt instead
      Project name: scs
      Project version: undefined
      Activating VS 17.12.2
      C compiler for the host machine: cl (msvc 19.42.34435 "Microsoft (R) C/C++ Optimizing Compiler Version 19.42.34435 for x64")
      C linker for the host machine: link link 14.42.34435.0
      Host machine cpu family: x86_64
      Host machine cpu: x86_64
      Program python found: YES (C:\Users\devap\AppData\Local\Programs\Python\Python313\python.exe)
      Library openblas found: NO
      Did not find pkg-config by name 'pkg-config'
      Found pkg-config: NO
      Found CMake: C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin\cmake.EXE (3.29.5)
      Run-time dependency openblas found: NO (tried pkgconfig and cmake)
      Run-time dependency openblas found: NO (tried pkgconfig and cmake)
      Library blas found: NO
      Run-time dependency blas found: NO (tried pkgconfig and cmake)
      Library lapack found: NO
      Run-time dependency lapack found: NO (tried pkgconfig and cmake)
      Library cblas found: NO
      Run-time dependency cblas found: NO (tried pkgconfig and cmake)

      ..\meson.build:48:4: ERROR: Problem encountered: OpenBLAS or Netlib BLAS/CBLAS is required on all platforms except Windows, and was not found.

      A full log can be found at C:\Users\devap\AppData\Local\Temp\pip-install-93vr0jcn\scs_5d6757b4a018456a9eafc172d72fa671\.mesonpy-uwreejb1\meson-logs\meson-log.txt
      [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.

I tried doing pip install meson thinking that it would solve the issue with the "Project does not target a minimum version but uses feature introduced in '1.1'" error, but that didn't help. I've also installed Build Tools as per the guide here: cvxpy_guide. It seems to be erroring when trying to install SCS, but I am unsure of what to do to actually fix this issue.


Solution

  • Ultimately, I just used conda to install cvxpy. Not too sure what was wrong with trying to install scs; I kept on running into the following error even after installing OpenBlas/Blas/etc. and making sure everything is up-to-date (pip, meson, numpy, scipy, etc.). For some reason, pkgconfig and cmake weren't able to detect OpenBlas:

    Collecting scs
      Using cached scs-3.2.7.tar.gz (1.6 MB)
      Installing build dependencies ... done
      Getting requirements to build wheel ... done
      Installing backend dependencies ... done
      Preparing metadata (pyproject.toml) ... error
      error: subprocess-exited-with-error
    
      × Preparing metadata (pyproject.toml) did not run successfully.
      │ exit code: 1
      ╰─> [124 lines of output]
          + meson setup C:\Users\devap\AppData\Local\Temp\pip-install-xw02b6ez\scs_da18bfd1c5e34f979872cf539352c02d C:\Users\devap\AppData\Local\Temp\pip-install-xw02b6ez\scs_da18bfd1c5e34f979872cf539352c02d\.mesonpy-5d8xc6p2 -Dbuildtype=release -Db_ndebug=if-release -Db_vscrt=md --native-file=C:\Users\devap\AppData\Local\Temp\pip-install-xw02b6ez\scs_da18bfd1c5e34f979872cf539352c02d\.mesonpy-5d8xc6p2\meson-python-native-file.ini
          The Meson build system
          Version: 1.6.0
          Source dir: C:\Users\devap\AppData\Local\Temp\pip-install-xw02b6ez\scs_da18bfd1c5e34f979872cf539352c02d
          Build dir: C:\Users\devap\AppData\Local\Temp\pip-install-xw02b6ez\scs_da18bfd1c5e34f979872cf539352c02d\.mesonpy-5d8xc6p2
          Build type: native build
          WARNING: Project does not target a minimum version but uses feature introduced in '1.1': meson.options file. Use meson_options.txt instead
          Project name: scs
          Project version: undefined
          Activating VS 17.12.2
          C compiler for the host machine: cl (msvc 19.42.34435 "Microsoft (R) C/C++ Optimizing Compiler Version 19.42.34435 for x64")
          C linker for the host machine: link link 14.42.34435.0
          Host machine cpu family: x86_64
          Host machine cpu: x86_64
          Program python found: YES (C:\Users\devap\AppData\Local\Programs\Python\Python313\python.exe)
          Library openblas found: NO
          Found pkg-config: YES (C:\Users\devap\pkg-configs\pkg-config.EXE) 0.26
          Found CMake: C:\Program Files\CMake\bin\cmake.EXE (3.31.1)
          Run-time dependency openblas found: NO (tried pkgconfig and cmake)
          Run-time dependency openblas found: NO (tried pkgconfig and cmake)
          Library blas found: NO
          Run-time dependency blas found: YES
          Library lapack found: NO
          Run-time dependency lapack found: NO (tried pkgconfig and cmake)
          Library cblas found: NO
          Run-time dependency cblas found: NO (tried pkgconfig and cmake)
          Compiler for C supports arguments -Wno-unused-result: NO
          Run-time dependency python found: YES 3.13
          Build targets in project: 2
          WARNING: Project specifies no minimum version but uses features which were added in versions:
           * 1.1: {'meson.options file'}
    
          scs undefined
    
            User defined options
              Native files: C:\Users\devap\AppData\Local\Temp\pip-install-xw02b6ez\scs_da18bfd1c5e34f979872cf539352c02d\.mesonpy-5d8xc6p2\meson-python-native-file.ini
              b_ndebug    : if-release
              b_vscrt     : md
              buildtype   : release
    
          Found ninja.EXE-1.11.1.git.kitware.jobserver-1 at C:\Users\devap\AppData\Local\Temp\pip-build-env-wyjerr1r\normal\Scripts\ninja.EXE
          + meson compile
          [1/45] Compiling C object _scs_direct.cp313-win_amd64.pyd.p/scs_source_src_scs_version.c.obj
          [2/45] Compiling C object _scs_direct.cp313-win_amd64.pyd.p/scs_source_src_normalize.c.obj
          [3/45] Compiling C object _scs_direct.cp313-win_amd64.pyd.p/scs_source_src_aa.c.obj
          [4/45] Compiling C object _scs_direct.cp313-win_amd64.pyd.p/scs_source_src_exp_cone.c.obj
          [5/45] Compiling C object _scs_direct.cp313-win_amd64.pyd.p/scs_source_src_linalg.c.obj
          [6/45] Compiling C object _scs_direct.cp313-win_amd64.pyd.p/scs_source_linsys_cpu_direct_private.c.obj
          [7/45] Compiling C object _scs_direct.cp313-win_amd64.pyd.p/scs_source_linsys_csparse.c.obj
          [8/45] Compiling C object _scs_direct.cp313-win_amd64.pyd.p/scs_scspy.c.obj
          [9/45] Compiling C object _scs_direct.cp313-win_amd64.pyd.p/scs_source_src_ctrlc.c.obj
          [10/45] Compiling C object _scs_direct.cp313-win_amd64.pyd.p/scs_source_linsys_external_amd_amd_global.c.obj
          [11/45] Compiling C object _scs_direct.cp313-win_amd64.pyd.p/scs_source_linsys_external_amd_amd_1.c.obj
          [12/45] Compiling C object _scs_direct.cp313-win_amd64.pyd.p/scs_source_linsys_external_amd_amd_aat.c.obj
          ../scs_source/linsys/external/amd/amd_aat.c(176): warning C4244: '=': conversion from 'scs_int' to 'scs_float', possible loss of data
          ../scs_source/linsys/external/amd/amd_aat.c(177): warning C4244: '=': conversion from 'scs_int' to 'scs_float', possible loss of data
          ../scs_source/linsys/external/amd/amd_aat.c(179): warning C4244: '=': conversion from 'scs_int' to 'scs_float', possible loss of data
          ../scs_source/linsys/external/amd/amd_aat.c(180): warning C4244: '=': conversion from 'size_t' to 'scs_float', possible loss of data
          [13/45] Compiling C object _scs_direct.cp313-win_amd64.pyd.p/scs_source_linsys_external_amd_amd_defaults.c.obj
          [14/45] Compiling C object _scs_direct.cp313-win_amd64.pyd.p/scs_source_src_rw.c.obj
          [15/45] Compiling C object _scs_direct.cp313-win_amd64.pyd.p/scs_source_src_util.c.obj
          [16/45] Compiling C object _scs_direct.cp313-win_amd64.pyd.p/scs_source_linsys_external_amd_amd_control.c.obj
          [17/45] Compiling C object _scs_direct.cp313-win_amd64.pyd.p/scs_source_linsys_external_qdldl_qdldl.c.obj
          [18/45] Compiling C object _scs_direct.cp313-win_amd64.pyd.p/scs_source_linsys_scs_matrix.c.obj
          [19/45] Compiling C object _scs_direct.cp313-win_amd64.pyd.p/scs_source_linsys_external_amd_amd_dump.c.obj
          [20/45] Compiling C object _scs_direct.cp313-win_amd64.pyd.p/scs_source_src_scs.c.obj
          [21/45] Compiling C object _scs_direct.cp313-win_amd64.pyd.p/scs_source_src_cones.c.obj
          [22/45] Compiling C object _scs_direct.cp313-win_amd64.pyd.p/scs_source_linsys_external_amd_amd_2.c.obj
          ../scs_source/linsys/external/amd/amd_2.c(603): warning C4244: '=': conversion from 'scs_float' to 'scs_int', possible loss of data
          ../scs_source/linsys/external/amd/amd_2.c(1525): warning C4244: '=': conversion from 'scs_int' to 'scs_float', possible loss of data
          ../scs_source/linsys/external/amd/amd_2.c(1526): warning C4244: '=': conversion from 'scs_int' to 'scs_float', possible loss of data
          ../scs_source/linsys/external/amd/amd_2.c(1563): warning C4244: '=': conversion from 'scs_int' to 'scs_float', possible loss of data
          ../scs_source/linsys/external/amd/amd_2.c(1593): warning C4244: '=': conversion from 'scs_int' to 'scs_float', possible loss of data
          ../scs_source/linsys/external/amd/amd_2.c(1599): warning C4244: '=': conversion from 'scs_int' to 'scs_float', possible loss of data
          [23/45] Compiling C object _scs_direct.cp313-win_amd64.pyd.p/scs_source_linsys_external_amd_amd_postorder.c.obj
          [24/45] Compiling C object _scs_direct.cp313-win_amd64.pyd.p/scs_source_linsys_external_amd_amd_preprocess.c.obj
          [25/45] Compiling C object _scs_direct.cp313-win_amd64.pyd.p/scs_source_linsys_external_amd_amd_order.c.obj
          ../scs_source/linsys/external/amd/amd_order.c(47): warning C4244: '=': conversion from 'scs_int' to 'scs_float', possible loss of data
          ../scs_source/linsys/external/amd/amd_order.c(66): warning C4244: '=': conversion from 'scs_int' to 'scs_float', possible loss of data
          ../scs_source/linsys/external/amd/amd_order.c(197): warning C4244: '=': conversion from 'scs_int' to 'scs_float', possible loss of data
          [26/45] Compiling C object _scs_direct.cp313-win_amd64.pyd.p/scs_source_linsys_external_amd_amd_post_tree.c.obj
          [27/45] Compiling C object _scs_direct.cp313-win_amd64.pyd.p/scs_source_linsys_external_amd_amd_info.c.obj
          [28/45] Compiling C object _scs_direct.cp313-win_amd64.pyd.p/scs_source_linsys_external_amd_SuiteSparse_config.c.obj
          [29/45] Compiling C object _scs_direct.cp313-win_amd64.pyd.p/scs_source_linsys_external_amd_amd_valid.c.obj
          [30/45] Compiling C object _scs_indirect.cp313-win_amd64.pyd.p/scs_source_src_aa.c.obj
          [31/45] Compiling C object _scs_indirect.cp313-win_amd64.pyd.p/scs_source_src_exp_cone.c.obj
          [32/45] Compiling C object _scs_indirect.cp313-win_amd64.pyd.p/scs_scspy.c.obj
          [33/45] Compiling C object _scs_indirect.cp313-win_amd64.pyd.p/scs_source_src_linalg.c.obj
          [34/45] Compiling C object _scs_indirect.cp313-win_amd64.pyd.p/scs_source_src_scs_version.c.obj
          [35/45] Compiling C object _scs_indirect.cp313-win_amd64.pyd.p/scs_source_src_normalize.c.obj
          [36/45] Compiling C object _scs_indirect.cp313-win_amd64.pyd.p/scs_source_src_ctrlc.c.obj
          [37/45] Linking target _scs_direct.cp313-win_amd64.pyd
          FAILED: _scs_direct.cp313-win_amd64.pyd
          "link"  /MACHINE:x64 /OUT:_scs_direct.cp313-win_amd64.pyd _scs_direct.cp313-win_amd64.pyd.p/scs_scspy.c.obj _scs_direct.cp313-win_amd64.pyd.p/scs_source_linsys_cpu_direct_private.c.obj _scs_direct.cp313-win_amd64.pyd.p/scs_source_src_aa.c.obj _scs_direct.cp313-win_amd64.pyd.p/scs_source_src_cones.c.obj _scs_direct.cp313-win_amd64.pyd.p/scs_source_src_ctrlc.c.obj _scs_direct.cp313-win_amd64.pyd.p/scs_source_src_exp_cone.c.obj _scs_direct.cp313-win_amd64.pyd.p/scs_source_src_linalg.c.obj _scs_direct.cp313-win_amd64.pyd.p/scs_source_src_normalize.c.obj _scs_direct.cp313-win_amd64.pyd.p/scs_source_src_rw.c.obj _scs_direct.cp313-win_amd64.pyd.p/scs_source_src_scs_version.c.obj _scs_direct.cp313-win_amd64.pyd.p/scs_source_src_scs.c.obj _scs_direct.cp313-win_amd64.pyd.p/scs_source_src_util.c.obj _scs_direct.cp313-win_amd64.pyd.p/scs_source_linsys_scs_matrix.c.obj _scs_direct.cp313-win_amd64.pyd.p/scs_source_linsys_csparse.c.obj _scs_direct.cp313-win_amd64.pyd.p/scs_source_linsys_external_qdldl_qdldl.c.obj _scs_direct.cp313-win_amd64.pyd.p/scs_source_linsys_external_amd_amd_1.c.obj _scs_direct.cp313-win_amd64.pyd.p/scs_source_linsys_external_amd_amd_2.c.obj _scs_direct.cp313-win_amd64.pyd.p/scs_source_linsys_external_amd_amd_aat.c.obj _scs_direct.cp313-win_amd64.pyd.p/scs_source_linsys_external_amd_amd_control.c.obj _scs_direct.cp313-win_amd64.pyd.p/scs_source_linsys_external_amd_amd_defaults.c.obj _scs_direct.cp313-win_amd64.pyd.p/scs_source_linsys_external_amd_amd_dump.c.obj _scs_direct.cp313-win_amd64.pyd.p/scs_source_linsys_external_amd_amd_global.c.obj _scs_direct.cp313-win_amd64.pyd.p/scs_source_linsys_external_amd_amd_info.c.obj _scs_direct.cp313-win_amd64.pyd.p/scs_source_linsys_external_amd_amd_order.c.obj _scs_direct.cp313-win_amd64.pyd.p/scs_source_linsys_external_amd_amd_post_tree.c.obj _scs_direct.cp313-win_amd64.pyd.p/scs_source_linsys_external_amd_amd_postorder.c.obj _scs_direct.cp313-win_amd64.pyd.p/scs_source_linsys_external_amd_amd_preprocess.c.obj _scs_direct.cp313-win_amd64.pyd.p/scs_source_linsys_external_amd_amd_valid.c.obj _scs_direct.cp313-win_amd64.pyd.p/scs_source_linsys_external_amd_SuiteSparse_config.c.obj "/release" "/nologo" "/OPT:REF" "/DLL" "/IMPLIB:_scs_direct.cp313-win_amd64.lib" "C:\Users\devap\AppData\Local\Programs\Python\Python313\libs\python313.lib" "kernel32.lib" "user32.lib" "gdi32.lib" "winspool.lib" "shell32.lib" "ole32.lib" "oleaut32.lib" "uuid.lib" "comdlg32.lib" "advapi32.lib"
             Creating library _scs_direct.cp313-win_amd64.lib and object _scs_direct.cp313-win_amd64.exp
          scs_source_src_aa.c.obj : error LNK2019: unresolved external symbol dnrm2_ referenced in function aa_safeguard
          scs_source_src_linalg.c.obj : error LNK2001: unresolved external symbol dnrm2_
          scs_source_src_aa.c.obj : error LNK2019: unresolved external symbol daxpy_ referenced in function aa_apply
          scs_source_src_linalg.c.obj : error LNK2001: unresolved external symbol daxpy_
          scs_source_src_aa.c.obj : error LNK2019: unresolved external symbol dgemv_ referenced in function relax
          scs_source_src_aa.c.obj : error LNK2019: unresolved external symbol dgesv_ referenced in function solve
          scs_source_src_aa.c.obj : error LNK2019: unresolved external symbol dgemm_ referenced in function set_m
          scs_source_src_aa.c.obj : error LNK2019: unresolved external symbol dscal_ referenced in function relax
          scs_source_src_cones.c.obj : error LNK2001: unresolved external symbol dscal_
          scs_source_src_linalg.c.obj : error LNK2001: unresolved external symbol dscal_
          scs_source_src_cones.c.obj : error LNK2019: unresolved external symbol dsyev_ referenced in function _scs_init_cone
          scs_source_src_cones.c.obj : error LNK2019: unresolved external symbol dsyrk_ referenced in function proj_semi_definite_cone
          scs_source_src_linalg.c.obj : error LNK2019: unresolved external symbol ddot_ referenced in function _scs_dot
          scs_source_src_linalg.c.obj : error LNK2019: unresolved external symbol idamax_ referenced in function _scs_norm_inf
    
          _scs_direct.cp313-win_amd64.pyd : fatal error LNK1120: 10 unresolved externals
    
          [38/45] Compiling C object _scs_indirect.cp313-win_amd64.pyd.p/scs_source_linsys_cpu_indirect_private.c.obj
          [39/45] Compiling C object _scs_indirect.cp313-win_amd64.pyd.p/scs_source_linsys_csparse.c.obj
          [40/45] Compiling C object _scs_indirect.cp313-win_amd64.pyd.p/scs_source_src_cones.c.obj
          [41/45] Compiling C object _scs_indirect.cp313-win_amd64.pyd.p/scs_source_src_rw.c.obj
          [42/45] Compiling C object _scs_indirect.cp313-win_amd64.pyd.p/scs_source_src_util.c.obj
          [43/45] Compiling C object _scs_indirect.cp313-win_amd64.pyd.p/scs_source_linsys_scs_matrix.c.obj
          [44/45] Compiling C object _scs_indirect.cp313-win_amd64.pyd.p/scs_source_src_scs.c.obj
          ninja: build stopped: subcommand failed.
          Activating VS 17.12.2
          INFO: automatically activated MSVC compiler environment
          INFO: autodetecting backend as ninja
          INFO: calculating backend command to run: C:\Users\devap\AppData\Local\Temp\pip-build-env-wyjerr1r\normal\Scripts\ninja.EXE
          [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.