问题
macos matlab2024a上安装cvx时报错。
安装来源:从官网下载cvx for mac的最新版本Download CVX | CVX Research, Inc.Download CVX | CVX Research, Inc.
cvx_setup时会报错:
>> cvx_setup
---------------------------------------------------------------------------
CVX: Software for Disciplined Convex Programming (c)2014 CVX Research
Version 2.2, Build 1148 (62bfcca) Tue Jan 28 00:51:35 2020
---------------------------------------------------------------------------
Installation info:
Path: /Users/zqz/Documents/MATLAB/cvx
MATLAB version: 24.1 (R2024a)
OS: Mac OS X aarch64 version 14.3
Java version: 11.0.22
Verfying CVX directory contents:
WARNING: The following files/directories are missing:
/Users/zqz/Documents/MATLAB/cvx/sedumi/.travis.yml
These omissions may prevent CVX from operating properly.
ERROR: one or more MEX files for this platform are missing.
These files end in the suffix ".mexmaca64". CVX will not operate
without these files. Please visit
http://cvxr.com/cvx/download
And download a distribution targeted for your platform.
Preferences: none found; defaults loaded.
UNEXPECTED ERROR: -------------------------
函数或变量 'command_str' 无法识别。
出错 cvx_license
出错 cvx_license
出错 cvx_version (第 309 行)
cvx_license( args{:} );
出错 cvx_setup (第 20 行)
cvx_version( '-install', varargin{:} );
-------------------------------------------
Please report this error to support, and include entire output of
CVX_SETUP in your support request.
---------------------------------------------------------------------------
原因应该是某些以.mexmaca64为后缀的文件没找到
解决方法
主要参考了Announcement: CVX for Apple Silicon - Meta - CVX Forum: a community-driven support forum这篇回答。
首先安装了里面提到的支持mac架构的cvx安装包(不知道是不是这个问题,也可能不用安)
下载之后可以看到,与原来直接官网下载的文件夹相比,lib里面多了两个以mexmaca64为后缀的文件:
继续cvx_setup安装,仍然会报错:
这个应该是因为这个包的来源不是appstore或者苹果支持的开发者,所以mac不信任。
即使在这里点【仍然允许】,但是下次继续安装的时候还是会报错。
参考这个人的回答,应该在安全设置中信任所有来源的文件:
但是我的安全里面没有allow anyway。
解决方案:
在命令行里输入:
sudo spctl --master-disable
现在安全性中出现了允许任何来源:
允许后再重新安装,即可安装成功:
>> cvx_setup
---------------------------------------------------------------------------
CVX: Software for Disciplined Convex Programming (c)2014 CVX Research
Version 2.2, Build 1148 (62bfcca) Tue Jan 28 00:51:35 2020
---------------------------------------------------------------------------
Installation info:
Path: /Users/zqz/Documents/MATLAB/cvx
MATLAB version: 24.1 (R2024a)
OS: Mac OS X aarch64 version 14.3
Java version: 11.0.22
Verfying CVX directory contents:
No missing files.
Preferences:
Path: /Users/zqz/Library/Application Support/MathWorks/MATLAB/cvx_prefs.mat
---------------------------------------------------------------------------
Setting CVX paths...already set!
Searching for solvers...4 shims found.
2 solvers initialized (* = default):
* SDPT3 4.0 {cvx}/sdpt3
SeDuMi 1.3.4 {cvx}/sedumi
2 solvers skipped:
GLPK
Could not find a GLPK installation.
Mosek unknown
Could not find a MOSEK MEX file.
Saving updated preferences...done.
Testing with a simple model...done!
---------------------------------------------------------------------------
To change the default solver, type "cvx_solver <solver_name>".
To save this change for future sessions, type "cvx_save_prefs".
Please consult the users' guide for more information.
--------------------------------------------------------------------------->> cvx_begin
>>