随笔-59  评论-36  文章-0  trackbacks-0
近来在做一个C++嵌入python的程序,刚开始一直在本机跑,一切正常,后来拿到别人机子上就无法运行了。本以为是缺少了python27.dll,结果发现不止缺少这一个文件,貌似还缺少很多python的库文件。

于是通过关键字“C++嵌入python 发布”,找到了一个用py2exe来解决问题,但我试了半天都没成功(也许是我自己没弄对的原因,因为人家都成功了)。
再后来我把关键字改为了“python C++ distribute embed”(即英文关键字),这下拨云见天了,因为在Google的第一页就有一个外国帖子其标题正和我意(果然英语给力)。

看了那个贴子发现,之所以不能在没有安装python的机子上运行是因为:


In addition to pythonxy.dll, you also need the entire Python library, i.e. the contents of the lib folder, plus the extension modules, i.e. the contents of the DLLs folder. Without the standard library, Python won't even start, since it tries to find os.py (in 3.x; string.py in 2.x). On startup, it imports a number of modules, in particular site.py.


原文:http://stackoverflow.com/questions/1387906/c-with-python-embedding-crash-if-python-not-installed
posted on 2011-04-25 09:57 zhaoyg 阅读(1253) 评论(0)  编辑 收藏 引用 所属分类: C++和Python

只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理