1

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: 找不到指定的模块。')

Nimantha
  • 6,405
  • 6
  • 28
  • 69
Lancdorr
  • 335
  • 4
  • 14

2 Answers2

0

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

ErlingMOSEK
  • 391
  • 1
  • 7
  • When I try to use the command ‘import mosek’, an error pops up: ImportError: DLL load failed while importing _msk: – Lancdorr Jan 10 '22 at 09:09
  • @Lancdorr It is as if something didn't install correctly. What is your operating system? Can you try reinstalling mosek? – Michal Adamaszek Jan 10 '22 at 09:25
  • @MichalAdamaszek Windows 11, I have uninstalled and reinstalled MOSEK several times. Should I download the full distribution? – Lancdorr Jan 10 '22 at 10:00
  • If you are sure "import mosek" tries to import mosek from your conda installation, and not from some older/different installation that you might have lying around in another place on your disk, then contact support@mosek.com with a complete log output from conda install and we will discuss it there. You can also try to install with pip and see if that makes a difference. – Michal Adamaszek Jan 10 '22 at 10:06
  • @MichalAdamaszek I just read the official documentation, which mentioned that MOSEK needs to set up LICENSE to run. And I haven't set it yet, could that be the reason? – Lancdorr Jan 10 '22 at 10:18
  • @MichalAdamaszek I have solved the license problem, but I still get this error when I run the program: Encountered unexpected exception importing solver GLPK and Encountered unexpected exception importing solver GLPK_MI – Lancdorr Jan 10 '22 at 11:00
  • The license should not come up so early as to prevent loading the module. About GLPK solver I cannot help much unfortunately. – Michal Adamaszek Jan 10 '22 at 11:05
0

Make sure your needed module is installed in the current selected environment. Open an new integrated Terminal and run conda list mosek, check if its location is the one shown in status bar:

enter image description here

Molly Wang-MSFT
  • 7,943
  • 2
  • 9
  • 22