Search code examples
pythonvisual-studio-codeanacondacvxpymosek

How to install mosek for cvxpy?


Previously I used command conda install -c mosek mosek to install mosek(my IDE is VS Code and use anaconda environment). After I installed it, I ran a program for a convex optimization problem, and one line of code was(because I want to choose mosek as solver):

prob.solve(solver=cp.MOSEK)

then an error pops up:

cvxpy.error.SolverError: The solver MOSEK is not installed.

BUT I have MOSEK installed. I used the following piece of code to detect:

import cvxpy as cp

print(cp.installed_solvers())

the result is:

['ECOS', 'ECOS_BB', 'OSQP', 'SCIPY', 'SCS']

Why does this happen?

I used the conda list command to check if I have mosek installed:

Related picture

But I did install it!

How can I solve it?


Besides, every time I run the program it pops up this error:

Encountered unexpected exception importing solver MOSEK:
ImportError('DLL load failed while importing _msk: 找不到指定的模块。')


Solution

  • Have you tested that your conda installed Mosek can be used outside Cvxpy i.e. directly from Python.