我们正试图通过PythonQT控制台在我们的QT C ++应用程序中使用 matlab引擎。普通的python命令在我们的应用程序的pythonQT控制台中工作,但是当我们尝试连接到matlab引擎时,它会挂起函数调用MatlabEngine::waitForMATLAB
(参见问题末尾的堆栈跟踪的第6行)。
我们运行了一个Matlab实例,并通过调用matlab.engine.shareEngine
来共享其引擎。在PythonQT控制台上,我们通过它连接到它
eng = matlab.engine.connect_matlab('XXXX')
。
这导致发动机(?)冻结。
注意:我们不直接从通用python终端连接 matlab引擎时出现问题。当我们从PythonQT终端访问它时,我们只遇到这个问题。
1 __psynch_cvwait
2 _pthread_cond_wait
3 std::condition_variable::__do_timed_wait(std::unique_lock<std::mutex>&, std::chrono::time_point<std::chrono::system_clock, std::chrono::duration<long long, std::ratio<1l, 1000000000l>>>)
4 std::cv_status std::condition_variable::wait_for<long long, std::ratio<1l, 1000000000l>>(std::unique_lock<std::mutex>&, std::chrono::duration<long long, std::ratio<1l, 1000000000l>> const&)
5 std::future_status std::__assoc_sub_state::wait_until<std::chrono::steady_clock, std::chrono::duration<long long, std::ratio<1l, 1000000000l>>>(std::chrono::time_point<std::chrono::steady_clock, std::chrono::duration<long long, std::ratio<1l, 1000000000l>>> const&) const
6 engine_api::waitMATLAB(unsigned long long, double)
7 MatlabEngine::waitForMATLAB(_object *, _object *)
8 PyEval_EvalFrameEx
9 ___lldb_unnamed_symbol1476$$Python
10 PyEval_EvalFrameEx
11 PyEval_EvalCodeEx
12 ___lldb_unnamed_symbol1476$$Python
13 PyEval_EvalFrameEx
14 PyEval_EvalCodeEx
15 ___lldb_unnamed_symbol1476$$Python
16 PyEval_EvalFrameEx
17 PyEval_EvalCodeEx
18 ___lldb_unnamed_symbol1476$$Python
19 PyEval_EvalFrameEx
20 PyEval_EvalCodeEx
21 PyEval_EvalCode
22 ___lldb_unnamed_symbol1599$$Python
23 PyRun_StringFlags
24 PythonQtScriptingConsole::executeCode(QString const&)
25 PythonQtScriptingConsole::executeLine(bool)
26 PythonQtScriptingConsole::keyPressEvent(QKeyEvent *)
27 QWidget::event(QEvent *)
28 QFrame::event(QEvent *)
29 QAbstractScrollArea::event(QEvent *)
30 QTextEdit::event(QEvent *)
31 QApplicationPrivate::notify_helper(QObject *, QEvent *)
32 QApplication::notify(QObject *, QEvent *)
33 QCoreApplication::notifyInternal2(QObject *, QEvent *)
34 ___lldb_unnamed_symbol542$$QtWidgets
35 QApplicationPrivate::notify_helper(QObject *, QEvent *)
36 QApplication::notify(QObject *, QEvent *)
37 QCoreApplication::notifyInternal2(QObject *, QEvent *)
38 QGuiApplicationPrivate::processKeyEvent(QWindowSystemInterfacePrivate::KeyEvent *)
39 QWindowSystemInterface::sendWindowSystemEvents(QFlags<QEventLoop::ProcessEventsFlag>)
40 QWindowSystemInterface::flushWindowSystemEvents(QFlags<QEventLoop::ProcessEventsFlag>)
41 ___lldb_unnamed_symbol405$$libqcocoa.dylib
42 ___lldb_unnamed_symbol406$$libqcocoa.dylib
43 -[NSWindow(NSEventRouting) _reallySendEvent:isDelayedEvent:]
44 -[NSWindow(NSEventRouting) sendEvent:]
45 ___lldb_unnamed_symbol169$$libqcocoa.dylib
46 ___lldb_unnamed_symbol152$$libqcocoa.dylib
47 -[NSApplication(NSEvent) sendEvent:]
48 ___lldb_unnamed_symbol583$$libqcocoa.dylib
49 -[NSApplication run]
50 ___lldb_unnamed_symbol505$$libqcocoa.dylib
51 QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>)
52 QCoreApplication::exec()
53 main
54 start
我在Matlab论坛上有open question,目前没有答案。
任何帮助或指示表示赞赏:)
NT