C++ Python 嵌入:在没有 Python 的机器上运行?
我正在尝试制作一个支持Python脚本的小游戏。我使用Python C-API没有任何问题,但我不知道如何确保游戏在没有安装Python的计算机上运行。
我知道我需要 pythonXY.dll ——还有什么?当我尝试运行该程序时,它告诉我找不到encodings.utf_8。我尝试将encodings/utf_8.py文件复制到与我的程序相同的目录中,但错误仍然弹出。
I'm trying to make a small game that supports Python scripting. I've no problems with using the Python C-API, but I don't know how to ensure that the game will run on a computer with no Python installed.
I know I need pythonXY.dll -- what else is there? When I try to run the program it tells me it cannot find encodings.utf_8. I tried copying the encodings/utf_8.py file in the same directory as my program, but the error still pops up.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要encodings/__init__.py文件,否则encodings是一个文件夹而不是python包。
您很可能需要 python 标准库中的很多东西。为了使一切正常工作,您需要将整个标准库与您的程序一起包含在内。
您可以通过将库放入 zip 文件并将其添加到 sys.path 来改善这一点。另外,您只能包含 pyc,而不包含原始 py 文件。
You need the
encodings/__init__.py
file, otherwise encodings is a folder and not a python package.Chances are that you'll need a lot of stuff from within the python standard library. To make everything just work you'll need to include the entire standard library along with your program.
You can make this a bit better by putting the library in a zip file and adding that to sys.path. Also, you can include only pyc not the original py files.