Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/visual-studio/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
将wxPython嵌入VisualStudio 2005 C/C++;失败_Python_Visual Studio_Visual C++_Wxpython - Fatal编程技术网

将wxPython嵌入VisualStudio 2005 C/C++;失败

将wxPython嵌入VisualStudio 2005 C/C++;失败,python,visual-studio,visual-c++,wxpython,Python,Visual Studio,Visual C++,Wxpython,当我尝试像这样在C中嵌入python wx时: #include "stdafx.h" #ifdef _DEBUG #undef _DEBUG #include <Python.h> #define _DEBUG #else #include <Python.h> #endif int _tmain(int argc, _TCHAR* argv[]) { PyObject* pyModule; Py_Initialize(); //_pyMo

当我尝试像这样在C中嵌入python wx时:

#include "stdafx.h"
#ifdef _DEBUG
  #undef _DEBUG
  #include <Python.h>
  #define _DEBUG
#else
  #include <Python.h>
#endif

int _tmain(int argc, _TCHAR* argv[])
{
  PyObject* pyModule;
  Py_Initialize();
  //_pyModule = PyImport_ImportModule("__main__");
  //_pyModule = PyImport_ImportModule("csi");
  pyModule = PyImport_ImportModule("wx");
  if(!pyModule)
    PyErr_Print();
  return 0;
}
#包括“stdafx.h”
#ifdef_调试
#未定义调试
#包括
#定义调试
#否则
#包括
#恩迪夫
int _tmain(int argc,_TCHAR*argv[]
{
PyObject*pyModule;
Py_初始化();
//_pyModule=PyImport\u ImportModule(“\uuu main\uuu”);
//_pyModule=PyImport_ImportModule(“csi”);
pyModule=PyImport_ImportModule(“wx”);
if(!pyModule)
PyErr_Print();
返回0;
}
它失败了:

->Traceback (most recent call last):
  File "C:\Python27\lib\site-packages\wx-2.8-msw-ansi\wx\__init__.py", line 45, in <module>
  from wx._core import *
  File "C:\Python27\lib\site-packages\wx-2.8-msw-ansi\wx\_core.py", line 4, in <module>
  import _core_
  ImportError: DLL load failed: The specified module could not be found.
->回溯(最近一次呼叫最后一次):
文件“C:\Python27\lib\site packages\wx-2.8-msw-ansi\wx\\uuuuu init\uuuuuu.py”,第45行,在
从wx.\u核心导入*
文件“C:\Python27\lib\site packages\wx-2.8-msw-ansi\wx\\ u core.py”,第4行,在
导入核心_
ImportError:DLL加载失败:找不到指定的模块。
msvc*90.dll文件可能有问题

我正在使用VS2005、Python2.7、Wxpython2.8.12.1(ansi)来实现Python2.7

还安装了更多MS VC++2008/2010可再发行版本


谢谢您的帮助。

我终于找到了解决方案:

这是一个明显的问题。多亏了微软的dll地狱

这有助于:

//_core_.pyd ImportError
// _core_.pyd is in fact a dll. it can be renamed.
// The problem is that _core_.pyd depends on some Microsoft.VC90.CRT libraries
//this dependency must be added to make it work
#pragma comment(linker, "\"/manifestdependency:type='win32' name='Microsoft.VC90.CRT' version='9.0.21022.8' processorArchitecture='x86' publicKeyToken='1fc8b3b9a1e18e3b' language='*'\"")

最后我找到了解决办法:

这是一个明显的问题。多亏了微软的dll地狱

这有助于:

//_core_.pyd ImportError
// _core_.pyd is in fact a dll. it can be renamed.
// The problem is that _core_.pyd depends on some Microsoft.VC90.CRT libraries
//this dependency must be added to make it work
#pragma comment(linker, "\"/manifestdependency:type='win32' name='Microsoft.VC90.CRT' version='9.0.21022.8' processorArchitecture='x86' publicKeyToken='1fc8b3b9a1e18e3b' language='*'\"")

你为什么这么做?你可以只使用WxWiWEDE,因为它实际上是C++。你为什么这么做?你可以只使用WxWiWiDs,因为它实际上是C++。这真的有效,我使用一个Python模块,它是一个扩展,当我在Windows上启动Python解释器并导入那个模块时,没有错误。但是,当我在使用boost python的项目中使用此模块时,
boost::python::import
(使用
PyImport\u ImportModule
)将始终抛出导入错误。这确实有效,我使用的python模块是一个扩展,当我在windows上启动python解释器并导入该模块时,没有错误。但是,当我在使用boostpython的项目中使用此模块时,
boost::python::import
(使用
PyImport\u ImportModule
)将始终抛出导入错误。