简体   繁体   English

如何在 MS Windows 上安装 CVXPY?

[英]How to install CVXPY on MS Windows?

I am trying to install CVXPY on windows.我正在尝试在 Windows 上安装 CVXPY。 I already had installed Anaconda, so I am following this steps.我已经安装了蟒蛇,所以我下面 这个步骤。 I updated anaconda to the latest version, and checked that the Visual Studio C++ compiler for Python was already installed on my computer.我将 anaconda 更新到最新版本,并检查我的计算机上是否已经安装了用于 Python 的 Visual Studio C++ 编译器。 After that I installed SCS from Anaconda running the command suggested:之后,我从 Anaconda 安装了 SCS,运行建议的命令:

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

This returned an error message:这返回了一条错误消息:

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.

I dont know what the blaze package is, something installed by anaconda I guess, so I unistalled it from pip and then installed scs ( I say this just in case it is important, the real problem comes now)我不知道 blaze 包是什么,我猜是由 anaconda 安装的,所以我从 pip 中卸载了它,然后安装了 scs (我说这是为了以防万一它很重要,现在真正的问题来了)

After installing SCS I installed CVXPY:安装 SCS 后,我安装了 CVXPY:

pip install cvxpy

Apparently no error mesdsages appeared during the installation, but then I run the nosetest:显然在安装过程中没有出现错误消息,但是我运行了nosetest:

nosetests cvxpy

And this returned 27 error messages that I have no idea how to solve.这返回了 27 条错误消息,我不知道如何解决。 ¿Anyone else had this problem and can give me some hints? ¿其他人有这个问题,可以给我一些提示吗?

(I paste here some of the error messages I get). (我在这里粘贴了我收到的一些错误消息)。

======================================================================
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)

@sacha is right. @sacha是正确的。 You must install SCS either from source or via the cvxgrp conda channel. 您必须从源代码或通过cvxgrp conda通道安装SCS。 The omnia version of SCS is not complete. SCS的omnia版本不完整。 But your installation is sufficient for solving many problems, just not SDPs. 但是您的安装足以解决许多问题,而不仅仅是SDP。 If you install MOSEK you can forget about SCS altogether. 如果您安装MOSEK,您可能会完全忘记SCS。

I'm getting a similar error as you. 我收到与您类似的错误。 So far this is what I've tried. 到目前为止,这是我尝试过的。 According to their website: 根据他们的网站:

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

and before the two I would install this: 在这两个之前,我将安装它:

conda install -c cvxgrp scs

@steven: I tried installing MOSEK and it made "nosetests cvxpy" brought up so many errors that it just crashed. @steven:我尝试安装MOSEK,它使“ nosetests cvxpy”出现了很多错误,以致于它崩溃了。

Here is what I did to install CVXPY for my Python 3.7这是我为 Python 3.7 安装 CVXPY 所做的工作

Step 1:第1步:

Go to https://www.lfd.uci.edu/~gohlke/pythonlibs/#scs and download the following files (you need to pick the one that matches your machine and Python versions, also the 2.0.7 number may be updated in the future).https://www.lfd.uci.edu/~gohlke/pythonlibs/#scs下载以下文件(你需要选择与你的机器和 Python 版本匹配的文件,2.0.7 编号可能会更新在将来)。 Mine were:我的是:

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

Step 2:第2步:

Go to your Anaconda directory, for example, mine is at C:\\users\\zyoung\\Anaconda3 ,find a folder named pkgs ,for example mine is C:\\users\\zyoung\\Anaconda3\\pkgs , save the 3 files from step 1 in this folder.进入你的 Anaconda 目录,例如我的是C:\\users\\zyoung\\Anaconda3 ,找到一个名为pkgs的文件夹,例如我的是C:\\users\\zyoung\\Anaconda3\\pkgs ,将步骤 1 中的 3 个文件保存在这个文件夹。

Step 3:第 3 步:

Open your Anaconda Prompt from cmd and go to the folder from step 2 and input the following commandscmd打开您的 Anaconda Prompt 并转到步骤 2 中的文件夹并输入以下命令

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

After successful install, input安装成功后,输入

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

After successful install, input安装成功后,输入

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

When this is successful, then you are done!当这成功时,你就完成了!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM