在 Windows 系统 OOTB 上使用 cx_Freeze (Python 2.7)
自从我开始使用Python以来,我就一直被这个问题所困扰,我想编写一个Python脚本,然后将其导出为可以在任何Windows XP(及更高版本)机器上运行的EXE。
cx_Freeze 完美地涵盖了所有这些,唯一的问题是它需要在客户端计算机上安装 Visual C++ 运行时,然后生成的 EXE 才能在客户端计算机上运行...
是否可以将我漂亮的 *.py 文件转换为漂亮的可分发文件EXE 可以在全新安装的 Windows XP 及更高版本上运行吗?
I have been plagued with this problem ever since I started with Python, I want to write a Python script, and then export it as an EXE that I can run on any Windows XP (and up) machine.
cx_Freeze covers all of this perfectly, the only problem is that it required Visual C++ Runtime to be installed on the client computer before the resulting EXE will run on it...
Is it possible to convert my beautiful *.py file into a nice distributable EXE that will run on a fresh install of Windows XP and up?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
据我所知,如果您拥有 Visual Studio 许可证,您就有权将适当的
msvcrXY.dll
与您的应用程序捆绑在一起。这将使其无需安装运行时文件即可运行。如果您没有 Visual Studio 许可证,我可以想到两种解决方案:
一种是将 VS 运行时安装程序与您的应用程序捆绑在一起(如果许可证允许),并制作一个运行以下命令的小型批处理文件/程序:如果需要的话,安装程序,然后是你的程序。如果用户没有管理员权限,则这并不理想。
我能想到的另一个选择是使用 Mingw-gcc 编译 Python,然后使用该 Python 创建冻结的可执行文件。这样就不会依赖VS运行时库了。这种方法当然要复杂得多,并且可能需要大量修改。也许有人已经做到了。
AFAIK if you have a Visual Studio licence, you have the right to bundle the appropriate
msvcrXY.dll
with your application. That will make it run without having to install the runtime files.If you don't have a Visual Studio licence, I can think of two solutions:
One is to bundle the VS runtime installer with your application (if that is allowed by the licence), and make a tiny batch file/program that runs the installer if necessary, and then your program. This is not ideal if e.g. the user doesn't have admin rights.
The other option I can think of is for you to compile Python with Mingw-gcc, and then use that Python to create your frozen executable. Then it won't depend on the VS runtime libraries. This approach is of course much more complicated and will probably require quite a bit of tinkering. Perhaps someone has already done it though.