將python文件打包exe獨立運行程序方法詳解
首先需要安裝pyinstaller庫。
pip install pyinstaller
exe程序打包步驟
cmd 進入要編譯的python文件所在的文件夾,
然后
pyinstaller -F hello.py
hello.py就是我要打包的文件。
常用參數(shù):
-F 生成單個的exe文件。
-w 隱藏運行窗口。
-h 可以查看幫助信息,更多指令可以通過這個查看。
最開始 D:\pyinstaller 目錄下只有hello.py這一個文件,其它的文件都是后生成的。
生成的exe文件在dist里,這個exe文件單獨拿出來放在任何的位置都可以運行。
編譯過程:
出現(xiàn)completed successfully就成功了。
96 INFO: PyInstaller: 3.4 96 INFO: Python: 3.6.8 97 INFO: Platform: Windows-7-6.1.7601-SP1 98 INFO: wrote D:\pyinstaller\hello.spec 105 INFO: UPX is not available. 107 INFO: Extending PYTHONPATH with paths ['D:\\pyinstaller', 'D:\\pyinstaller'] 107 INFO: checking Analysis 108 INFO: Building Analysis because Analysis-00.toc is non existent 108 INFO: Initializing module dependency graph... 110 INFO: Initializing module graph hooks... 112 INFO: Analyzing base_library.zip ... 4577 INFO: running Analysis Analysis-00.toc 4582 INFO: Adding Microsoft.Windows.Common-Controls to dependent assemblies of f inal executable required by d:\python3.6.8\python.exe 5582 INFO: Caching module hooks... 5590 INFO: Analyzing D:\pyinstaller\hello.py 5596 INFO: Loading module hooks... 5597 INFO: Loading module hook "hook-encodings.py"... 5845 INFO: Loading module hook "hook-pydoc.py"... 5847 INFO: Loading module hook "hook-xml.py"... 6152 INFO: Looking for ctypes DLLs 6152 INFO: Analyzing run-time hooks ... 6164 INFO: Looking for dynamic libraries 6287 INFO: Looking for eggs 6287 INFO: Using Python library d:\python3.6.8\python36.dll 6288 INFO: Found binding redirects: [] 6294 INFO: Warnings written to D:\pyinstaller\build\hello\warn-hello.txt 6349 INFO: Graph cross-reference written to D:\pyinstaller\build\hello\xref-hell o.html 6357 INFO: checking PYZ 6358 INFO: Building PYZ because PYZ-00.toc is non existent 6359 INFO: Building PYZ (ZlibArchive) D:\pyinstaller\build\hello\PYZ-00.pyz 7000 INFO: Building PYZ (ZlibArchive) D:\pyinstaller\build\hello\PYZ-00.pyz comp leted successfully. 7006 INFO: checking PKG 7007 INFO: Building PKG because PKG-00.toc is non existent 7007 INFO: Building PKG (CArchive) PKG-00.pkg 8818 INFO: Building PKG (CArchive) PKG-00.pkg completed successfully. 8822 INFO: Bootloader d:\python3.6.8\lib\site-packages\PyInstaller\bootloader\Wi ndows-32bit\run.exe 8822 INFO: checking EXE 8823 INFO: Building EXE because EXE-00.toc is non existent 8824 INFO: Building EXE from EXE-00.toc 8826 INFO: Appending archive to EXE D:\pyinstaller\dist\hello.exe
更多關(guān)于將python文件打包exe獨立運行程序方法請查看下面的相關(guān)鏈接
相關(guān)文章
python利用os模塊編寫文件復(fù)制功能——copy()函數(shù)用法
這篇文章主要介紹了python利用os模塊編寫文件復(fù)制功能——copy()函數(shù)用法,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2020-07-07Python3多進程 multiprocessing 模塊實例詳解
這篇文章主要介紹了Python3多進程 multiprocessing 模塊,結(jié)合實例形式詳細分析了Python3多進程 multiprocessing 模塊的概念、原理、相關(guān)方法使用技巧與注意事項,需要的朋友可以參考下2018-06-06python 用opencv實現(xiàn)圖像修復(fù)和圖像金字塔
這篇文章主要介紹了python 如何用opencv實現(xiàn)圖像修復(fù)和圖像金字塔,幫助大家更好的理解和使用python處理圖片,感興趣的朋友可以了解下2020-11-11使用python計算方差方式——pandas.series.std()
這篇文章主要介紹了使用python計算方差方式——pandas.series.std(),具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教2022-05-05Python實現(xiàn)將Excel轉(zhuǎn)換成xml的方法示例
這篇文章主要介紹了Python實現(xiàn)將Excel轉(zhuǎn)換成xml的方法,涉及Python針對Excel文件的讀取、遍歷、節(jié)點設(shè)置與xml生成等相關(guān)操作技巧,需要的朋友可以參考下2018-08-08