简体   繁体   English

如何为 cvxpy 安装 mosek?

[英]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).以前我使用命令conda install -c mosek mosek安装 mosek(我的 IDE 是 VS Code 并使用 anaconda 环境)。 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):安装好之后,我运行了一个凸优化问题的程序,一行代码是(因为我想选择mosek作为求解器):

prob.solve(solver=cp.MOSEK)

then an error pops up:然后弹出一个错误:

cvxpy.error.SolverError: The solver MOSEK is not installed. cvxpy.error.SolverError:未安装求解器MOSEK。

BUT I have MOSEK installed.但是我安装了 MOSEK。 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:我使用conda list命令检查是否安装了 mosek:

相关图片

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:导入求解器MOSEK时遇到意外异常:
ImportError('DLL load failed while importing _msk: 找不到指定的模块。') ImportError('DLL load failed while importing _msk: 找不到指定的模块。')

Have you tested that your conda installed Mosek can be used outside Cvxpy ie directly from Python.您是否测试过您的 conda 安装 Mosek 可以在 Cvxpy 之外使用,即直接从 Python 使用。

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:打开一个新的集成终端并运行conda list mosek ,检查它的位置是否是状态栏中显示的位置:

在此处输入图像描述

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

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