Python 使用 Anaconda 将 .py 转换为 .exe

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/44089420/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-19 23:43:16  来源:igfitidea点击:

Converting .py to .exe with Anaconda

pythonpython-2.7anacondaexe

提问by Luis Dias

I made a python program using PyGame which is only available for Python 2.7 so that is my python version. I am using Anaconda because it is easier to install modules and to use python, but the site hasn't py2exe module for 2.7. Is there another way to convert it? Or some way to install py2exe for 2.7 in Anaconda?

我使用 PyGame 制作了一个仅适用于 Python 2.7 的 Python 程序,因此这是我的 Python 版本。我使用 Anaconda 是因为它更容易安装模块和使用 python,但该站点没有 2.7 的 py2exe 模块。有没有其他方法可以转换它?或者有什么方法可以在 Anaconda 中为 2.7 安装 py2exe?

回答by Rui Filipe

How to create an executable using Anaconda 3 (specifically Anaconda Prompt) for Windows.

如何使用适用于 Windows 的 Anaconda 3(特别是 Anaconda Prompt)创建可执行文件。

1 - Make sure pyinstaller is installed in your anaconda

1 - 确保 pyinstaller 安装在您的 anaconda 中

pip install pyinstaller

pip 安装 pyinstaller

2 - Move to the directory of your python script

2 - 移动到你的 python 脚本目录

cd C:\Users....\program.py

cd C:\用户....\program.py

3 - Just type the following:

3 - 只需输入以下内容:

pyinstaller --onefile program.py

pyinstaller --onefile 程序.py

If everything goes well, in the folder where you have your script.py you it will be created many folders and your executable is inside folder "dist".

如果一切顺利,在您拥有 script.py 的文件夹中,您将创建许多文件夹,您的可执行文件位于文件夹“dist”中。

If my explanation is confusing go here: https://medium.com/dreamcatcher-its-blog/making-an-stand-alone-executable-from-a-python-script-using-pyinstaller-d1df9170e263

如果我的解释令人困惑,请转到此处:https: //medium.com/dreamcatcher-its-blog/making-an-stand-alone-executable-from-a-python-script-using-pyinstaller-d1df9170e263

回答by Marcel S.

Instead of using py2exe you could try to build your executable with pyinstaller.

您可以尝试使用 pyinstaller 构建可执行文件,而不是使用 py2exe。

http://www.pyinstaller.org/downloads.html

http://www.pyinstaller.org/downloads.html

The PyGame package is also supported with pyinstaller according to this link

根据此链接,pyinstaller 也支持 PyGame 包

https://github.com/pyinstaller/pyinstaller/wiki/Supported-Packages

https://github.com/pyinstaller/pyinstaller/wiki/Supported-Packages