当前位置:网站首页>Calling Matlab configuration in pycharm: No module named 'matlab.engine'; 'matlab' is not a package
Calling Matlab configuration in pycharm: No module named 'matlab.engine'; 'matlab' is not a package
2022-08-05 05:24:00 【When you are full, you will be strong】
使用Pycharm配置调用matlab经验分享,Read the post summed up,Mainly the article:python调用matlab的方法记录
matlab2018b支持python3.5、3.6但是不支持python3.7.如果遇到不匹配的情况,记得把python的版本降低,或者安装更新版本的matlab,比如:matlab2020b
1. 首先找到matlab安装路径,我的路径在:D:\matlab2020b\extern\engines\python,如下:
This is after the success of the installation directory

2. 利用命令行,cmd,到D:\matlab2020b\extern\engines\python文件夹下,然后依次执行下面命令.
python setup.py build --build-base="builddir" install
python setup.py install --prefix="installdir"
python setup.py build --build-base="builddir" install --prefix="installdir"
python setup.py install --user
例如:
After the success of the installation using the following code to test whether can run:
import matlab.engine
from numpy import *
if __name__ == '__main__':
eng = matlab.engine.start_matlab('MATLAB_R2019b')
A = matlab.double([[1, 2], [5, 6]])
print(type(A), A.size, A)
print(eng.eig(A))
eng.quit()
pass
如果测试报错:No module named ‘matlab.engine’; ‘matlab’ is not a package
记得查看pythonThe interpreter paths are generated insidematlab文件,例如下面的图片:
D:\python3.7\venv\Lib\site-packages\matlab
如果没有,那么把D:\matlab2020b\extern\engines\python下的dist中的matlab文件复制python解释器路径.
如果还是报错,可能的原因如下:
1.Copy the wrong path,检查python解释器路径.
2.D:\matlab2020b\extern\engines\python路径下的matlab的包错误,导致出现问题.Reinstall or directly to find an already installedmatlab复制到python解释器路径.
链接:https://pan.baidu.com/s/1t3fOUrCsh_MHdwludo7h8w
提取码:rjle
–来自百度网盘超级会员V4的分享
python里调用matlab脚本,参考:参考
matlab中编写:
function hellomatlab()
clear
sum = 0;
for i = 1:100
sum = sum +i;
disp(['sum=',num2str(sum)]);
end
pycharm中编写:
import matlab
import matlab.engine
engine = matlab.engine.start_matlab() # 启动matlab engine
engine.hellomatlab(nargout = 0)
注意:matlab代码和pythonCode needs to be in the same directory
调用结果:
边栏推荐
- 使用二维码解决固定资产管理的难题
- 02.01-----参数的引用的作用“ & ”
- Using pip to install third-party libraries in Pycharm fails to install: "Non-zero exit code (2)" solution
- 【技能】长期更新
- 【过一下11】随机森林和特征工程
- vscode+pytorch使用经验记录(个人记录+不定时更新)
- range函数作用
- redis事务
- 2022杭电多校第一场01
- Error creating bean with name 'configDataContextRefresher' defined in class path resource
猜你喜欢

flex布局青蛙游戏通关攻略
![[Let's pass 14] A day in the study room](/img/fc/ff4161db8ed13a0c8ef75b066b8eab.png)
[Let's pass 14] A day in the study room

第5讲 使用pytorch实现线性回归

The mall background management system based on Web design and implementation

【练一下1】糖尿病遗传风险检测挑战赛 【讯飞开放平台】

第三讲 Gradient Tutorial梯度下降与随机梯度下降

The fourth back propagation back propagation
![[Go through 3] Convolution & Image Noise & Edge & Texture](/img/7b/2214020cadf06d9211fd40fb5f1b63.png)
[Go through 3] Convolution & Image Noise & Edge & Texture

【过一下 17】pytorch 改写 keras

Flutter real machine running and simulator running
随机推荐
entry point injection
电话溥功能
Lecture 5 Using pytorch to implement linear regression
vscode+pytorch使用经验记录(个人记录+不定时更新)
类的底层机制
Xiaobai, you big bulls are lightly abused
Distributed systems revisited: there will never be a perfect consistency scheme...
2022 The 4th C.Easy Counting Problem (EGF+NTT)
Flutter real machine running and simulator running
Wise Force Deleter强制删除工具
human weakness
【过一下8】全连接神经网络 视频 笔记
第四讲 反向传播随笔
2022 Hangzhou Electric Multi-School 1st Session 01
2022杭电多校第一场01
【过一下9】卷积
入口点注入
OFDM Lecture 16 5 -Discrete Convolution, ISI and ICI on DMT/OFDM Systems
【过一下12】整整一星期没记录
ES6 生成器