py_initialize:C调Python出错是初始化错误?
还是pythonpath和pythonname变量没有配置正确?
In an application embedding Python, this should be called before using any other Python/C API functions; with the exception of Py_SetProgramName(), Py...
在嵌套Python的应⽤中,应该在使⽤任何Python/C API⽅法之前调⽤该⽅法;
C++调Python⽰例
程序刚开始运⾏到Py_Initialize()函数,报错:ImportError:Nomodulenamedsite如遇到这个函数报错那么基本上就是你没有将相关路径添加到环境变量中。两个⽅法:⼀个就是补全python的环境变量。另⼀个就是⼿动设置初始化函数的搜寻路径(也就是加载路径)环境变量设置⽅法⾃⼰去⽹上⼀堆。⼿动添加搜寻路径函数为:Py_SetPythonHome("python的安装路径");//如:C:/Python27;只需要到最外层就可以啦
程序刚开始运⾏到Py_Initialize()函数,报错:ImportError: No module named site
如遇到这个函数报错那么基本上就是你没有将相关路径添加到环境变量中。
两个⽅法:
⼀个就是补全python的环境变量。
另⼀个就是⼿动设置初始化函数的搜寻路径(也就是加载路径)
环境变量设置⽅法⾃⼰去⽹上⼀堆。 ⼿动添加搜寻路径函数为:Py_SetPythonHome("python的安装路径");//如:C:/Python27;只需要到最外层就可以啦 以上是关于vs2010调⽤python中Py_Initialize函数报错的原因的内容,更多 调⽤ initialize 函数 原因 Python Vs2010 关于 py 的内容,请您使⽤右上⽅搜索功能获取相关信息。 C++调⽤Python Py_Initializez中断: 2017年11⽉13⽇ 19:58:40
weixin_38105245 阅读数:1690 C++中调⽤Python代码,但是在Py_Initialize函数调⽤时就中断了,程序是64位的 python是3.5.3的64位版本 。 简单的调⽤代码如下: #include "stdafx.h" #include "Python.h" int _tmain(int argc, _TCHAR* argv[]) { Py_Initialize(); Py_Finalize(); return 0; } 运⾏结果: '' (Win32): Loaded 'C:\Windows\SysWOW64\advapi32.dll'. Cannot find or open the PDB file. '' (Win32): Loaded 'C:\Windows\SysWOW64\sechost.dll'. Cannot find or open the PDB file. '' (Win32): Loaded 'C:\Windows\SysWOW64\rpcrt4.dll'. Cannot find or open the PDB file. '' (Win32): Loaded 'C:\Windows\SysWOW64\sspicli.dll'. Cannot find or open the PDB file.
'' (Win32): Loaded 'C:\Windows\SysWOW64\cryptbase.dll'. Cannot find or ope
n the PDB file.python默认安装路径
'' (Win32): Loaded 'C:\Windows\SysWOW64\shell32.dll'. Cannot find or open the PDB file.
'' (Win32): Loaded 'C:\Windows\SysWOW64\shlwapi.dll'. Cannot find or open the PDB file.
'' (Win32): Loaded
'C:\Windows\winsxs\x86__1fc8b3b9a1e18e3b_9.0.30729.4940_none_50916076bcb9a742\msvcr90.dll'. Cannot find or open the PDB file. '' (Win32): Loaded 'C:\Windows\SysWOW64\imm32.dll'. Cannot find or open the PDB file. '' (Win32): Loaded 'C:\Windows\SysWOW64\msctf.dll'. Cannot find or open the PDB file. The program '[43084] ' has exited with code 1 (0x1). 没有任何错误提⽰ 运⾏到Py_Initialize 程序直接崩溃 ---------------------------------------------------------------------------------------------- 搞了⼀天终于搞明⽩,解决⽅案是在Py_Initialize函数前加⼀⾏Py_SetPythonHome(L"D:\\Python35")

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。