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 ...
随机推荐
- Android Theme的使用
原文地址 http://www.cnblogs.com/Dentist/p/4369816.html Theme是一套UI控件和Activity的样式.可以给Application 和 activit ...
- 让Delphi XE5跟其他版本的Delphi共存
找到Delphi XE5的安装根目录 .... \Program Files (x86)\Embarcadero\RAD Studio\12.0\bin下的cglm.ini文件, 打开cglm.i ...
- contOS 下安装mysql
一.mysql简介 说到数据库,我们大多想到的是关系型数据库,比如mysql.oracle.sqlserver等等,这些数据库软件在windows上安装都非常的方便,在Linux上如果要安装数据库,咱 ...
- Oracle LSNRCTL------监听器的启动和关闭
对于DBA来说,启动和关闭oracle监听器是很基础的任务,但是Linux系统管理员或者程序员有时也需要在开发数据库中做一些基本的DBA操作,因此了解一些基本的管理操作对他们来说很重要. 本文将讨论用 ...
- Train-Alypay-Cloud:蚂蚁金融云知识点
ylbtech-Train-Alypay-Cloud:蚂蚁金融云知识点 1.返回顶部 1. 1.数据库与缓存结合使用https://www.cloud.alipay.com/docs/2/47337 ...
- 第14 章 Spring MVC的工作机制与设计模式
14.1 Spring MVC的总体设计 要使用SPring MVC,只要在web.xml中配置一个DispatcherServlet. 再定义一个dispatcherServlet-servlet. ...
- js操作history
js操作history pushState pushState只会在当前history中添加一条记录,并不会刷新浏览器 history.pushState({}, "my title&quo ...
- springboot成神之——websocket发送和请求消息
本文介绍如何使用websocket发送和请求消息 项目目录 依赖 DemoApplication MessageModel WebConfig WebSocketConfig HttpHandshak ...
- CodeIgniter框架隐藏index.php
问题描述:使用CodeIgniter框架做项目时,在启用REWRITE的伪静态功能的时候,首页可以访问,但是访问其它页面的时候,就提示:“No input file specified.” 原因在于使 ...
- IDEA实用的第三方插件和工具介绍设置
一:grep console grep-console插件可以让idea显示多颜色调试日志,使Log4j配置输出的不同级别error warn info debug fatal显示不同颜色 开发起来区 ...