Search code examples
pythonpython-2.7installationanacondacvxpy

How to install CVXPY on MS Windows?


I am trying to install CVXPY on windows. 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. After that I installed SCS from Anaconda running the command suggested:

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)

After installing SCS I installed CVXPY:

pip install cvxpy

Apparently no error mesdsages appeared during the installation, but then I run the nosetest:

nosetests cvxpy

And this returned 27 error messages that I have no idea how to solve. ¿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)

Solution

  • @sacha is right. You must install SCS either from source or via the cvxgrp conda channel. The omnia version of SCS is not complete. But your installation is sufficient for solving many problems, just not SDPs. If you install MOSEK you can forget about SCS altogether.