尝试从C+;执行python脚本时出现导入错误+;在Visual Studio 2013-15中
我目前正在与Keras合作一个手势识别项目。 因此,我安装了Anaconda和Python2.7,并编写了一些与Spyder配合良好的脚本尝试从C+;执行python脚本时出现导入错误+;在Visual Studio 2013-15中,python,c++,visual-studio,python-2.7,numpy,Python,C++,Visual Studio,Python 2.7,Numpy,我目前正在与Keras合作一个手势识别项目。 因此,我安装了Anaconda和Python2.7,并编写了一些与Spyder配合良好的脚本 之后,我想从我的主软件Visual Studio 2015 C++项目中使用它们。 因此,我使用“python.h”来实现这一点,但我有导入问题 例如,如果我尝试执行以下代码: PyObject *pName, *pModule, *pDict, *pFunc, *pValue; // Initialize the Python Interp
之后,我想从我的主软件Visual Studio 2015 C++项目中使用它们。 因此,我使用“python.h”来实现这一点,但我有导入问题
例如,如果我尝试执行以下代码:PyObject *pName, *pModule, *pDict, *pFunc, *pValue; // Initialize the Python Interpreter
Py_Initialize();
FILE *fd = fopen("test.py","r");
PyFile_FromString("test.py", "r");
PyRun_SimpleFileEx(PyFile_AsFile(PyFileObject),"test.py", 1); //file before returning.
Py_Finalize();
cout << "Press any key to exit" << endl;
_getch();
Traceback (most recent call last):
File "test.py", line 4, in <module>
from numpy import numpy
ImportError: cannot import name numpy
Press any key to exit
from time import time,ctime
from numpy import np
np.random.seed(1337)
//No need to add more code for this example
print ('Today is',ctime(time()))
我仍然是Python的初学者,所以我看到缺少了一些lib,但我不明白为什么它在Spyder中工作,但在这里不工作
谢谢你的关注 好的,我修好了。事实上,我的电脑上有两个pythons版本,visualstudio拿错了一个。好的,我修复了它。事实上,我的电脑上有两个pythons版本,visualstudio拿错了一个