terminate called after throwing an instance of 'std::bad_alloc' what(): std::bad_alloc

在添加了

import matlab

import matlab.engine出现如下错误:

terminate called after throwing an instance of 'std::bad_alloc' what(): std::bad_alloc

经过python console测试到,上述的两个import语句其实都没有产生问题。

后来发现,我的上述两句import语句,位于.py文件的import文件的末尾,所以出现题目中的报错问题,如下图:

terminate called after throwing an instance of 'std::bad_alloc' what(): std::bad_alloc

解决方案,把两个import语句挪动到上面去,就可以解决,如下图所示:

terminate called after throwing an instance of 'std::bad_alloc' what(): std::bad_alloc