.PY 转换为 .EXE Python 2.6
我正在尝试将我的 .PY 脚本转换为 .EXE 文件,在此过程中我使用以下命令行尝试了 PY2EXE 。 python C:\Users\Noob\Desktop\setup.py py2exe -p ftplib -> -p ftplib 用于我的模块导入。 当我使用这段代码时,我留下了一个 .EXE 和一堆文件,如果我取出 .EXE ,那么它会出现错误。需要有“_socket.pyd”和“python26.dll”,否则它将崩溃(程序)。如果没有这些额外的文件,我该如何编译它(不必使用 PY2EXE 或必须使用它)? 多谢!
I'm trying to convert my .PY script into a .EXE file, in the process I have tried PY2EXE with the following command line..python C:\Users\Noob\Desktop\setup.py py2exe -p ftplib
-> -p ftplib is for my module import.
When I use this code, I'm left with an .EXE and a bunch of files, if I take the .EXE out then it will come up with an error. It is required to have "_socket.pyd" and "python26.dll" or it will crash (the program). How do I compile this (not having to use PY2EXE or having to use it) without these extra files?
Thanks a lot!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您不应该将 exe 从文件夹中取出并执行。只需从创建的
dist
目录中执行它,它包含可执行文件所需的 python26.dll 。如果您想发送它,请压缩 dist 目录并发送它。否则,您必须使用特定的安装程序软件(如 NSIS)创建安装程序。我希望您看一下 Python2.6 特定部分,其中有详细信息关于如何编写 data_files 以包含 msvcr90.dll
另外,我发现这个
-p ftplib
cmd 选项非常新。通常所有要做的事情都在 setup.py 中。您能指出哪里提到了这种选项规范吗?You should not be taking the exe out of your folder and executing. Just execute it from the
dist
directory where got created, it has the python26.dll which the executable needs. If you want to ship it, zip the dist directory and ship it. Otherwise you have to create an installer using specific installer software like NSIS.I hope you took a look at the Python2.6 specific section, which has details on how to write data_files to include msvcr90.dll
Also, I am finding this
-p ftplib
cmd option pretty new. Usually all things to do are within setup.py. Can you point out where this kind of option specification is mentioned.可以使用 py2exe 制作单个文件可执行文件,
setup.py
文件如下所示:请参阅py2exe 的选项列表 了解更多信息。另请查看“这些文件是什么?” 常见问题解答中的问题。
您可能还想看看 PyInstaller (它似乎在创建单个文件 exe 方面做得更好如果需要,请包含 Microsoft MSVCR*.DLL 文件)请务必在 Windows 上使用 1.5 系列的 python 2.6 。
It is possible to make single file executables with py2exe, the
setup.py
file would look something like this:See py2exe's list of options for more info. Also have a look at the "What are all those files?" question from the FAQ.
You might also want to have a look at PyInstaller (which seems to be doing a better job of creating single file exe's with Microsoft MSVCR*.DLL files included if you need those) Be sure to use the 1.5 series for python 2.6 on Windows.