我想從 python 文件創建一個可執行文件,該 python 文件是為 Python 2.7 編寫的。我嘗試過pyinstaller,但安裝時出現錯誤。我猜它不再支持Python 2.7。pyinstaller對于使用 Python 2.7 來說,有其他選擇嗎?我嘗試安裝cx_Freeze5.1.1 版本,但出現以下錯誤:Cleaning up...Command C:\Python27\python.exe -c "import setuptools, tokenize;__file__='c:\\users\\win-10\\appdata\\local\\temp\\pip_build_win-10\\cx-Freeze\\setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record c:\users\win-10\appdata\local\temp\pip-cn4sd_-record\install-record.txt --single-version-externally-managed --compile failed with error code 1 in c:\users\win-10\appdata\local\temp\pip_build_win-10\cx-FreezeStoring debug log for failure in C:\Users\win-10\pip\pip.log當我從輪子安裝時cx_Freeze-5.1.1-cp27-cp27m-win_amd64.whl is not a supported wheel on this platform.Storing debug log for failure in C:\Users\win-10\pip\pip.logsetup.pyfrom sys import executablefrom cx_Freeze import setup, Executablesetup(name='server', version='0.1', description='reverse shell server')
1 回答

慕無忌1623718
TA貢獻1744條經驗 獲得超4個贊
實現一個簡單的似乎過于復雜.exe
,所以我研究了文檔并找到了我需要的東西。如果您需要對 Python 2.x 的支持,則應使用 cx_Freeze 版本 5.1.x,只需運行即可pip install cx-Freeze==5.1.1
打開項目文件夾并在其中創建一個
setup.py
包含以下內容的文件:
import sys
from cx_Freeze import setup, Executable
setup(? name = "myProgram",
? ? ? ? version = "0.1",
? ? ? ? description = "",
? ? ? ? executables = [Executable("myProgram.py")])
設置這個文件需要一點研究,有多個選項需要設置。您可以設置選項來創建一個簡單的安裝程序
.exe
,也可以創建一個 windows/mac/linux 安裝程序。準備好文件并使用所需的選項后,只需在文件
setup.py
所在的目錄中打開 shell/terminal/cmd 并執行:python setup.py build
現在,在您的項目文件夾中,您將看到一個文件夾,您可以在其中找到您的
.exe
文件。
添加回答
舉報
0/150
提交
取消