python - 在我的 Qt C++ 应用程序中使用 Anaconda 的 Python

标签 python c++ qt anaconda

我打算在我的 Qt C++ 应用程序中使用 Anaconda 的 Python 从我的 C++ 代码中调用一些 scikit-learn 算法。出于某种原因,我无法弄清楚如何进行整合。我想知道是否有人知道这样做的分步程序。

最佳答案

如果您的 C++ 代码适用于 Qt <= 5.9.7。 (或更准确地说 Anaconda's current Qt version) 您可以通过添加

INCLUDEPATH += /home/[username]/anaconda3/include/python3.6m

LIBS += -L/home/[username]/anaconda3/lib/ -lpython3.6m

到您的 .pro 文件。

如果您需要高于 Anaconda 提供的 Qt 版本,请查看 my question here .现在您应该能够在您的应用程序中包含 Python.h header 。

备注:请记住,Python 提供了自己的信号和槽机制,这显然与 Qt 的机制冲突。这就是为什么我添加了

CONFIG += no_keywords

添加到我的 pro 文件,并替换所有出现的信号和插槽,如所述 here .

关于python - 在我的 Qt C++ 应用程序中使用 Anaconda 的 Python,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55003461/

相关文章:

c++ - 函数指针和继承

c++ - DEPLOYMENT qmake变量的目的是什么?

c++ - 我如何将 C++ 与 Flex 结合使用?

c++ - Qt 在 Windows 中部署应用程序需要的 dll

巨大的 C++ 预编译 header

python - 如何选择一个 html 元素,无论它在 selenium 中的哪个框架?

c++ - Qt - 如何从线程创建 QFuture

python - 双下划线__在python中是什么意思?

python - numpy distutils——尝试编译一些东西并在失败时设置标志

python - 无法使用 python azure-storage-file-datalake SDK 在 Azure Data Lake Gen2 中创建追加 Blob