问题描述
我的问题是关于将Python 3.5解释器嵌入C ++程序以从C ++接收图像,并将其用作我训练有素的Tensorflow模型的输入.当我在python代码中导入tensorflow库时出现错误(其他库工作正常).简化的代码如下:
My question is regarding embedding Python 3.5 interpreter in a C++ program to receive an image from C++, and use it as an input for my trained tensorflow model. When I import tensorflow library in my python code I get an error (other libraries work fine). The simplified code is as follows:
#include <string>
#include <windows.h>
#include <stdio.h>
int main()
{
Py_InitializeEx(1);
PyObject* sysPath = PySys_GetObject((char*)"path");
PyObject* curDir = PyUnicode_FromString(".");
PyList_Append(sysPath, curDir);
Py_DECREF(curDir);
PyRun_SimpleString("import tensorflow\n"
"print(tensorflow.__version__)\n");
Py_Finalize();
return 0;
}
错误是:
序号225不能位于动态链接库中 libiomp5md.dll.
The ordinal 225 could not be located in the dynamic link library libiomp5md.dll.
好
按确定"后,此错误将出现在控制台中:
And after pressing OK, this error appears in console:
我的设置是在Windows 7 x64,Anaconda Python 3.5.2,tensorflow-1.1.0和CUDA 8上进行的.
My setup is on Windows 7 x64, Anaconda Python 3.5.2, tensorflow-1.1.0 and CUDA 8.
这是类似的问题,但有不同的错误.
This is a similar problem with a different error.
感谢您的帮助.
推荐答案
我已通过将libiomp5md.dll
从python库文件夹复制到我的C ++代码目录中来解决此问题.
I've fixed this problem by copying libiomp5md.dll
from python library folder to directory of my C++ code.
这篇关于在C ++中的嵌入式Python中导入Tensorflow时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!