[英]How do I convert my code from python3.6 to exe using cxfreeze?
NOTE: Before marking this as duplicate please read the whole post first 注意:将其标记为重复之前,请先阅读整篇文章
I'm trying for hours to convert my python 3.6 code to exe, I've searched everywhere and tried everything, the most helpful place was there: Best method of converting .py to .exe for Python 3.6? 我试图将我的python 3.6代码转换为exe数小时,我到处搜索并尝试了所有方法,其中最有用的地方是: 为Python 3.6将.py转换为.exe的最佳方法?
So apparently there are only 3 ways of converting py to exe: 因此,显然只有3种将py转换为exe的方法:
Pyinstaller doesn't support Python 3.6, and py2exe is very outdated. Pyinstaller不支持Python 3.6,而py2exe已经过时了。
As for cxfreeze, it sounds like it supports Python 3.6, so that's the route that I've taken. 至于cxfreeze,听起来好像它支持Python 3.6,所以这就是我采取的方法。
I've searched everywhere on how to use cxfreeze, unfortunately, all guides that I have found seem to be outdated: 我到处搜索了如何使用cxfreeze,不幸的是,我发现的所有指南似乎都已过时:
http://cx-freeze.readthedocs.io/en/latest/overview.html this guide for example has three routes, two of which doesn't work (The first gives me a .spec file that i dont know what to do with it and the second gives me an error because i dont have the cxfreeze.util module) and the 3rd is too complicated for my tastes http://cx-freeze.readthedocs.io/en/latest/overview.html例如,本指南有3条路由,其中2条不起作用(第一个给我一个.spec文件,我不知道该怎么做第二个给我一个错误,因为我没有cxfreeze.util模块),第三个对我来说太复杂了
How do I use cx_freeze? 如何使用cx_freeze? this uses the second route, still it doesn't work
这使用第二条路线,但仍然行不通
I'm not allowed to comment for some reason, so this isn't really an answer, but for my part I installed cx_Freeze from https://pypi.python.org/pypi/cx_Freeze 由于某种原因,我不允许发表评论,因此这并不是真正的答案,但是就我而言,我从https://pypi.python.org/pypi/cx_Freeze安装了cx_Freeze
When you install it, there's an extra step that's not documented. 安装它时,还有一个未记录的额外步骤。 Using the Windows CMD shell, go to your python installation directory, into the Scripts sub-directory and you will find a few files called cxfreeze...
使用Windows CMD Shell,转到python安装目录,进入Scripts子目录,您将找到一些名为cxfreeze的文件。
You need to create the batch file by typing python cxfreeze-postinstall 您需要通过键入python cxfreeze-postinstall创建批处理文件
A file called cxfreeze.bat will be created which you can move into your main python folder or wherever your python program is located. 将创建一个名为cxfreeze.bat的文件,您可以将其移动到主python文件夹中或您的python程序所在的位置。
Then type cxfreeze mypythonprogram.py --target-dir dist 然后输入cxfreeze mypythonprogram.py --target-dir dist
This should create a working exe in the dist directory. 这应该在dist目录中创建一个正常工作的exe。 However, it doesn't work for me as I get an error in the finder.py file which is part of the cxfreeze installation so I don't know if I've done something wrong or this version is completely buggy.
但是,它对我不起作用,因为在finder.py文件中出现错误,该文件是cxfreeze安装的一部分,所以我不知道我做错了什么还是该版本完全有问题。
edit: by commenting out line 561 in the finder.py file (C:\\Python\\Python36-32\\Lib\\site-packages\\cx_Freeze\\finder.py on my system) I was able to run it and Generate the EXE which appears to run OK. 编辑:通过在finder.py文件中注释掉第561行(在我的系统上为C:\\ Python \\ Python36-32 \\ Lib \\ site-packages \\ cx_Freeze \\ finder.py),我能够运行它并生成出现的EXE运行确定。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.