我想把.py文件转换成.exe文件,这样我就可以在网页上执行它们。然而。每一种方法都涉及到pyinstaller,我不知道如何安装。有人能解释一下获得pyinstaller的过程,还是告诉我是否有其他方法可以不使用pyinstaller就将.py转换为.exe?
发布于 2021-01-06 14:46:13
安装Pyinstaller
安装pyinstaller非常简单和直接。您所要做的就是pip install pyinstaller或python -m pip install pyinstaller (显然您必须确保您的python和pip在PATH中),检查pyinstaller是否正确安装,只需在cmd中键入pyinstaller,如果没有出现错误,这意味着您已经安装了pyinstaller。如果由于某种原因,pyinstaller安装正确,但仍然不能工作,您可能需要将其添加到PATH中。可以考虑将C:\Users\user_name\AppData\Roaming\Python\Python37\Scripts添加到Path中。
使用Pyinstaller
要将.py文件转换为.exe文件,可以运行以下命令(确保您与您的python文件位于同一个目录中)-
pyinstaller file_name.py --简单地将您的python转换为一个可执行文件。这将创建一些文件夹和文件,当您运行.exe文件时,它将打开控制台并运行您的脚本。
pyinstaller -w file_name.py --通过添加一个-w,在运行.exe时控制台将不再出现。
pyinstaller -F file_name.py --通过添加一个-F,只会创建一个文件夹,该文件夹将包含您的.exe,而不包含其他文件。
pyinstaller -i icon.ico filename.py -通过添加一个-i,您将能够添加一个.ico文件作为您的图标。
当然,你可以结合使用标志来达到更好的效果。
外部链接
使用pyinstaller - https://pyinstaller.readthedocs.io/en/stable/usage.html#options
安装pyinstaller - https://pyinstaller.readthedocs.io/en/stable/installation.html#installing-in-windows
pyinstaller - https://pyinstaller.readthedocs.io/en/stable/operating-mode.html的工作
https://stackoverflow.com/questions/65597342
复制相似问题