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示例
https://www.cnblogs.com/Hisin/archive/2012/02/27/2370590.html
程序刚开始运行到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;
}
运行结果:
'TestEmbedPython.exe' (Win32): Loaded 'C:\Windows\SysWOW64\advapi32.dll'. Cannot find or open the PDB file.
'TestEmbedPython.exe' (Win32): Loaded 'C:\Windows\SysWOW64\sechost.dll'. Cannot find or open the PDB file.
'TestEmbedPython.exe' (Win32): Loaded 'C:\Windows\SysWOW64\rpcrt4.dll'. Cannot find or open the PDB file.
'TestEmbedPython.exe' (Win32): Loaded 'C:\Windows\SysWOW64\sspicli.dll'. Cannot find or open the PDB file.
'TestEmbedPython.exe' (Win32): Loaded 'C:\Windows\SysWOW64\cryptbase.dll'. Cannot find or open the PDB file.
'TestEmbedPython.exe' (Win32): Loaded 'C:\Windows\SysWOW64\shell32.dll'. Cannot find or open the PDB file.
'TestEmbedPython.exe' (Win32): Loaded 'C:\Windows\SysWOW64\shlwapi.dll'. Cannot find or open the PDB file.
'TestEmbedPython.exe' (Win32): Loaded 'C:\Windows\winsxs\x86_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.30729.4940_none_50916076bcb9a742\msvcr90.dll'. Cannot find or open the PDB file.
'TestEmbedPython.exe' (Win32): Loaded 'C:\Windows\SysWOW64\imm32.dll'. Cannot find or open the PDB file.
'TestEmbedPython.exe' (Win32): Loaded 'C:\Windows\SysWOW64\msctf.dll'. Cannot find or open the PDB file.
The program '[43084] TestEmbedPython.exe' has exited with code 1 (0x1).
没有任何错误提示 运行到Py_Initialize 程序直接崩溃
----------------------------------------------------------------------------------------------
搞了一天终于搞明白,解决方案是在Py_Initialize函数前加一行Py_SetPythonHome(L"D:\\Python35")
py_initialize:C调Python出错 是初始化错误?的更多相关文章
- Python程序的常见错误(收集篇)
关于Python Python是一门解释性的,面向对象的,并具有动态语义的高级编程语言.它高级的内置数据结构,结合其动态类型和动态绑定的特性,使得它在快速应用程序开发(Rapid Applicatio ...
- C++调Python示例(转载)
C++调Python,代码粘贴如下: #include <iostream> #include <Python.h> using namespace std; void Hel ...
- python学习笔记014——错误和异常
Python有两种错误很容易辨认:语法错误和异常. 1 什么是语法错误 Python 的语法错误或者称之为解析错,是初学者经常碰到的,如下实例 if i>4 print("if语句输出 ...
- Python 新手常犯错误
Python 新手常犯错误(第二部分) 转发自:http://blog.jobbole.com/43826/ 作用域 在这篇文章里,我们来关注作用域在Python被误用的地方.通常,当我们定义了一个全 ...
- python中常见的错误
python中常见的错误 1.IndentationError: unindent does not match any outer indentation leve 众所周知,Python语法要 ...
- Python:no encoding declared 错误
使用Python编译的时候出现如下错误: SyntaxError: Non-ASCII character ‘\xe5’ in file magentonotes.com.py on line 2, ...
- Python学习笔记七-错误和异常
程序员总是和各种错误打交道,学习如何识别并正确的处理程序错误是很有必要的. 7.1错误和异常 1.错误 从软件方面来看,错误分为语法错误和逻辑错误两种.这两种错误都将导致程序无法正常进行下去,当Pyt ...
- Python更新pip出现错误解决方法
Python更新pip出现错误解决方法 更新pip python -m pip install --upgrade pip 查看时报错 解决方法 在命令栏(即win+r)输入:easy_install ...
- Python学习 Part6:错误和异常
Python学习 Part6:错误和异常 两种不同类型的错误:语法错误和异常 1. 语法错误 语法错误,也被称作解析错误: >>> while True print('Hello w ...
随机推荐
- Dell 12G服务器 手动安装RedHat 6.X
12代服务器,是DELL目前最新产品,有R720,R520,R620,R420,M420 等产品 以下是光盘直接安装Red Hat 6.X 的方法步骤: 1,选择安装盘对应的启动设备 开机按F11,选 ...
- POJ2142(扩展欧几里得)
The Balance Time Limit: 5000MS Memory Limit: 65536K Total Submissions: 5991 Accepted: 2605 Descr ...
- mac 在终端使用命令行启动脚本,无法使用自己安装的python去执行脚本问题
参考了2片文章: //查看python位置 which python //先备份 1.sudo cp /usr/bin/python /usr/bin/python_cp //删除 2.sudo rm ...
- [新手教程]windows 2003 php环境搭建详细教程(转)
对于windows服务器的php环境配置一直是是新人朋友的难题,也难倒了很多高手.这里分享一个新手教程,给那些建站新人使用.本教程来自朋友吴文辉的博客,欢迎大家有时间可以访问他的博客:吴文辉博客htt ...
- spring mvc helloworld 和表单功能、页面重定向
Spring MVC Hello World 例子 这里有个很好的教程:https://www.cnblogs.com/wormday/p/8435617.html 下面的例子说明了如何使用 Spri ...
- HTTP 2 的新特性你 get 了吗?
导语 HTTP/2 的主要设计思想应该都是源自 Google的 SPDY 协议,是互联网工程任务组 ( IETF ) 对谷歌提出的 SPDY 协议进行标准化才有了现在的 HTTP/2 .下面我们直奔主 ...
- Eclipse 代码风格配置
代码风格配置:
- SQL Where 字符串拼接
) set @s='1,2,3' --法一: --法二: exec('select * from tb where id in ('+@s+')')
- 解决Axis2在webservice中遇到特殊字符的无法传输的缺陷(<CDATA>数据类型)
在使用Axis2进行soa webservice开发时,遇到类似以下的错误信息: com.ctc.wstx.sw.BaseStreamWriter.writeCharacters(BaseStream ...
- 编译错误error: invalid&nbsp…
昨天遇到一个莫名其妙的编译错误,以前没有见过,而且代码流程看起来也没有太多的奇异之处.后来忍无可忍,百度了下,发现别人也有遇到这个错误的,他的解决方法是:少了"}". 嘿嘿,我开始 ...