1

我正在尝试在 Windows 上安装 CVXPY。我已经安装了 Anaconda,所以我正在按照这些步骤操作。我将 anaconda 更新到了最新版本,并检查了我的计算机上是否已经安装了适用于 Python 的 Visual Studio C++ 编译器。之后,我从 Anaconda 安装 SCS,运行建议的命令:

conda install -c https://conda.anaconda.org/omnia scs

这返回了一条错误消息:

Solving environment: failed

UnsatisfiableError: The following specifications were found to be in conflict:
    - blaze
    - scs
Use "conda info <package>" to see the dependencies for each package.

我不知道 blaze 包是什么,我猜是 anaconda 安装的东西,所以我从 pip 中卸载了它,然后安装了 scs(我这样说是为了以防万一它很重要,现在真正的问题来了)

安装 SCS 后,我安装了 CVXPY:

pip install cvxpy

显然在安装过程中没有出现错误消息,但是我运行了nosetest:

nosetests cvxpy

这返回了 27 条我不知道如何解决的错误消息。¿ 其他人有这个问题,可以给我一些提示吗?

(我在这里粘贴了一些我收到的错误消息)。

======================================================================
ERROR: Failure: ImportError (cannot import name SymbolicQuadForm)
----------------------------------------------------------------------
Traceback (most recent call last):
File "C:\Users\alvaromc317\Anaconda2\lib\site-packages\nose\loader.py", line 418, in loadTestsFromName
    addr.filename, addr.module)
File "C:\Users\alvaromc317\Anaconda2\lib\site-packages\nose\importer.py", line 47, in importFromPath
    return self.importFromDir(dir_path, fqname)
File "C:\Users\alvaromc317\Anaconda2\lib\site-packages\nose\importer.py", line 94, in importFromDir
    mod = load_module(part_fqname, fh, filename, desc)
File "C:\Users\alvaromc317\Anaconda2\lib\site-packages\cvxpy\reductions\__init__.py", line 25, in <module>
    from cvxpy.reductions.dcp2cone.cone_matrix_stuffing import ConeMatrixStuffing
File "C:\Users\alvaromc317\Anaconda2\lib\site-packages\cvxpy\reductions\dcp2cone\cone_matrix_stuffing.py", line 24, in <module>
    from cvxpy.reductions.matrix_stuffing import extract_mip_idx, MatrixStuffing
File "C:\Users\alvaromc317\Anaconda2\lib\site-packages\cvxpy\reductions\matrix_stuffing.py", line 25, in <module>
    from cvxpy.utilities.coeff_extractor import CoeffExtractor
File "C:\Users\alvaromc317\Anaconda2\lib\site-packages\cvxpy\utilities\coeff_extractor.py", line 31, in <module>
    from cvxpy.utilities.replace_quad_forms import replace_quad_forms
File "C:\Users\alvaromc317\Anaconda2\lib\site-packages\cvxpy\utilities\replace_quad_forms.py", line 20, in <module>
    from cvxpy.atoms.quad_form import SymbolicQuadForm, QuadForm
ImportError: cannot import name SymbolicQuadForm

======================================================================
ERROR: cvxpy.tests.test_constant_atoms.test_atom(<function <lambda> at 0x0000000008C444A8>, Problem(Maximize(Expression(CONCAVE, UNKNOWN, (1, 1))), []), -0.34481428, 'SCS')
----------------------------------------------------------------------
Traceback (most recent call last):
File "C:\Users\alvaromc317\Anaconda2\lib\site-packages\nose\case.py", line 197, in runTest
    self.test(*self.arg)
File "C:\Users\alvaromc317\Anaconda2\lib\site-packages\cvxpy\tests\test_constant_atoms.py", line 295, in run_atom
    raise e
SolverError: Solver 'SCS' failed. Try another solver.
-------------------- >> begin captured stdout << ---------------------
FATAL: Cannot solve SDPs with > 2x2 matrices without linked blas+lapack libraries
Install blas+lapack and re-compile SCS with blas+lapack libray locations
ERROR: initCone failure
Failure:could not initialize work

--------------------- >> end captured stdout << ----------------------
======================================================================
ERROR: test_log_det (cvxpy.tests.test_examples.TestExamples)
----------------------------------------------------------------------
Traceback (most recent call last):
File "C:\Users\alvaromc317\Anaconda2\lib\site-packages\cvxpy\tests\test_examples.py", line 344, in test_log_det
    result = p.solve()
File "C:\Users\alvaromc317\Anaconda2\lib\site-packages\cvxpy\problems\problem.py", line 209, in solve
    return self._solve(*args, **kwargs)
File "C:\Users\alvaromc317\Anaconda2\lib\site-packages\cvxpy\problems\problem.py", line 335, in _solve
    self._update_problem_state(results_dict, sym_data, solver)
File "C:\Users\alvaromc317\Anaconda2\lib\site-packages\cvxpy\problems\problem.py", line 447, in _update_problem_state
    "Solver '%s' failed. Try another solver." % solver.name())
SolverError: Solver 'SCS' failed. Try another solver.
-------------------- >> begin captured stdout << ---------------------
FATAL: Cannot solve SDPs with > 2x2 matrices without linked blas+lapack libraries
Install blas+lapack and re-compile SCS with blas+lapack libray locations
ERROR: initCone failure
Failure:could not initialize work

--------------------- >> end captured stdout << ----------------------

======================================================================
ERROR: Test a problem with diag.
----------------------------------------------------------------------
Traceback (most recent call last):
File "C:\Users\alvaromc317\Anaconda2\lib\site-packages\cvxpy\tests\test_problem.py", line 1379, in test_diag_prob
    result = prob.solve()
File "C:\Users\alvaromc317\Anaconda2\lib\site-packages\cvxpy\problems\problem.py", line 209, in solve
    return self._solve(*args, **kwargs)
File "C:\Users\alvaromc317\Anaconda2\lib\site-packages\cvxpy\problems\problem.py", line 335, in _solve
    self._update_problem_state(results_dict, sym_data, solver)
File "C:\Users\alvaromc317\Anaconda2\lib\site-packages\cvxpy\problems\problem.py", line 447, in _update_problem_state
    "Solver '%s' failed. Try another solver." % solver.name())
SolverError: Solver 'SCS' failed. Try another solver.
-------------------- >> begin captured stdout << ---------------------
FATAL: Cannot solve SDPs with > 2x2 matrices without linked blas+lapack libraries
Install blas+lapack and re-compile SCS with blas+lapack libray locations
ERROR: initCone failure
Failure:could not initialize work

--------------------- >> end captured stdout << ----------------------

======================================================================
ERROR: Test positive definite constraints.
----------------------------------------------------------------------
Traceback (most recent call last):
File "C:\Users\alvaromc317\Anaconda2\lib\site-packages\cvxpy\tests\test_problem.py", line 1464, in test_psd_constraints
    result = prob.solve()
File "C:\Users\alvaromc317\Anaconda2\lib\site-packages\cvxpy\problems\problem.py", line 209, in solve
    return self._solve(*args, **kwargs)
File "C:\Users\alvaromc317\Anaconda2\lib\site-packages\cvxpy\problems\problem.py", line 335, in _solve
    self._update_problem_state(results_dict, sym_data, solver)
File "C:\Users\alvaromc317\Anaconda2\lib\site-packages\cvxpy\problems\problem.py", line 447, in _update_problem_state
    "Solver '%s' failed. Try another solver." % solver.name())
SolverError: Solver 'SCS' failed. Try another solver.
-------------------- >> begin captured stdout << ---------------------
FATAL: Cannot solve SDPs with > 2x2 matrices without linked blas+lapack libraries
Install blas+lapack and re-compile SCS with blas+lapack libray locations
ERROR: initCone failure
Failure:could not initialize work

--------------------- >> end captured stdout << ----------------------


======================================================================
ERROR: Failure: ImportError (cannot import name QuadForm)
----------------------------------------------------------------------
Traceback (most recent call last):
File "C:\Users\alvaromc317\Anaconda2\lib\site-packages\nose\loader.py", line 418, in loadTestsFromName
    addr.filename, addr.module)
File "C:\Users\alvaromc317\Anaconda2\lib\site-packages\nose\importer.py", line 47, in importFromPath
    return self.importFromDir(dir_path, fqname)
File "C:\Users\alvaromc317\Anaconda2\lib\site-packages\nose\importer.py", line 94, in importFromDir
    mod = load_module(part_fqname, fh, filename, desc)
File "C:\Users\alvaromc317\Anaconda2\lib\site-packages\cvxpy\tests\test_qp.py", line 25, in <module>
    from cvxpy.atoms import (QuadForm, abs, power, quad_over_lin, sum, sum_squares, norm,
ImportError: cannot import name QuadForm

======================================================================
ERROR: Test sdp var.
----------------------------------------------------------------------
Traceback (most recent call last):
File "C:\Users\alvaromc317\Anaconda2\lib\site-packages\cvxpy\tests\test_scs.py", line 85, in test_sdp_var
    prob.solve(verbose=True, solver=SCS)
File "C:\Users\alvaromc317\Anaconda2\lib\site-packages\cvxpy\problems\problem.py", line 209, in solve
    return self._solve(*args, **kwargs)
File "C:\Users\alvaromc317\Anaconda2\lib\site-packages\cvxpy\problems\problem.py", line 335, in _solve
    self._update_problem_state(results_dict, sym_data, solver)
File "C:\Users\alvaromc317\Anaconda2\lib\site-packages\cvxpy\problems\problem.py", line 447, in _update_problem_state
    "Solver '%s' failed. Try another solver." % solver.name())
SolverError: Solver 'SCS' failed. Try another solver.
-------------------- >> begin captured stdout << ---------------------
----------------------------------------------------------------------------
        SCS v1.2.6 - Splitting Conic Solver
        (c) Brendan O'Donoghue, Stanford University, 2012-2016
----------------------------------------------------------------------------
Lin-sys: sparse-indirect, nnz in A = 15, CG tol ~ 1/iter^(2.00)
eps = 1.00e-03, alpha = 1.50, max_iters = 2500, normalize = 1, scale = 1.00
Variables n = 6, constraints m = 15
Cones:  primal zero / dual free vars: 9
        sd vars: 6, sd blks: 1
FATAL: Cannot solve SDPs with > 2x2 matrices without linked blas+lapack libraries
Install blas+lapack and re-compile SCS with blas+lapack libray locations
ERROR: initCone failure
Setup time: 2.45e-04s
Failure:could not initialize work

--------------------- >> end captured stdout << ----------------------

======================================================================
ERROR: Test sigma_max.
----------------------------------------------------------------------
Traceback (most recent call last):
File "C:\Users\alvaromc317\Anaconda2\lib\site-packages\cvxpy\tests\test_scs.py", line 75, in test_sigma_max
    result = prob.solve(solver=SCS)
File "C:\Users\alvaromc317\Anaconda2\lib\site-packages\cvxpy\problems\problem.py", line 209, in solve
    return self._solve(*args, **kwargs)
File "C:\Users\alvaromc317\Anaconda2\lib\site-packages\cvxpy\problems\problem.py", line 335, in _solve
    self._update_problem_state(results_dict, sym_data, solver)
File "C:\Users\alvaromc317\Anaconda2\lib\site-packages\cvxpy\problems\problem.py", line 447, in _update_problem_state
    "Solver '%s' failed. Try another solver." % solver.name())
SolverError: Solver 'SCS' failed. Try another solver.
-------------------- >> begin captured stdout << ---------------------
FATAL: Cannot solve SDPs with > 2x2 matrices without linked blas+lapack libraries
Install blas+lapack and re-compile SCS with blas+lapack libray locations
ERROR: initCone failure
Failure:could not initialize work

--------------------- >> end captured stdout << ----------------------

----------------------------------------------------------------------
Ran 1775 tests in 14.630s

FAILED (errors=27)
4

3 回答 3

2

@sacha 是对的。您必须从源代码或通过 cvxgrp conda 通道安装 SCS。SCS 的omnia 版本并不完整。但是您的安装足以解决许多问题,而不是 SDP。如果你安装了 MOSEK,你可以完全忘记 SCS。

于 2018-04-30T18:20:00.020 回答
0

我遇到了和你类似的错误。到目前为止,这是我尝试过的。根据他们的网站:

conda install -c conda-forge lapack
conda install -c cvxgrp cvxpy

在这两个之前我会安装这个:

conda install -c cvxgrp scs

@steven:我尝试安装 MOSEK,但它使“nosetests cvxpy”出现了很多错误,以至于它崩溃了。

于 2019-01-04T03:13:34.687 回答
0

这是我为我的 Python 3.7 安装 CVXPY 所做的

步骤1:

访问https://www.lfd.uci.edu/~gohlke/pythonlibs/#scs 并下载以下文件(您需要选择与您的机器和 Python 版本相匹配的文件,并且 2.0.7 号可能会更新在将来)。我的是:

ecos-2.0.7.post1-cp37-cp37m-win_amd64.whl
scs-2.1.3-cp37-cp37m-win_amd64.whl
cvxpy-1.1.12-cp37-cp37m-win_amd64.whl

第2步:

进入你的 Anaconda 目录,例如我的在C:\users\zyoung\Anaconda3,找到一个名为 的文件夹pkgs,例如我的是C:\users\zyoung\Anaconda3\pkgs,将步骤 1 中的 3 个文件保存在这个文件夹中。

第 3 步:

打开您的 Anaconda Prompt fromcmd并转到步骤 2 中的文件夹并输入以下命令

C:\users\zyoung\Anaconda3>cd pkgs
C:\users\zyoung\Anaconda3\pkgs> pip install ecos-2.0.7.post1-cp37-cp37m-win_amd64.whl

安装成功后输入

pip install scs-2.1.3-cp37-cp37m-win_amd64.whl

安装成功后输入

pip install cvxpy-1.1.12-cp37-cp37m-win_amd64.whl

当这成功时,你就完成了!

于 2021-05-07T13:41:34.017 回答