Python鏄竴绉嶉珮绾х紪绋嬭瑷锛屽畠鍏锋湁鏄撳鏄撶敤銆佽法骞冲彴绛変紭鐐癸紝鍥犳鍦ㄥ紑鍙戜腑寰楀埌浜嗗箍娉涚殑搴旂敤銆

鐒惰岋紝Python浠g爜闇瑕佸湪Python瑙i噴鍣ㄤ腑杩愯锛岃繖瀵逛簬涓浜涚敤鎴锋潵璇村彲鑳戒笉澶柟渚裤

鍥犳锛屽皢Python浠g爜鎵撳寘鎴愬彲鎵ц鏂囦欢锛坋xe锛夋槸涓绉嶅緢濂界殑瑙e喅鏂规銆

鏈枃灏嗕粙缁6绉嶅皢Python浠g爜鎵撳寘鎴恊xe搴旂敤鐨勬柟寮忋

绗竴绉嶆柟寮忔槸浣跨敤pyinstaller銆俻yinstaller鏄竴涓祦琛岀殑Python鎵撳寘宸ュ叿锛屽畠鍙互灏哖ython浠g爜鎵撳寘鎴愮嫭绔嬬殑鍙墽琛屾枃浠躲傚彧闇瑕佸湪鍛戒护琛屼腑杈撳叆"pyinstaller your_script.py"锛屽氨鍙互鐢熸垚涓涓彲鍦╓indows銆丩inux鍜孧acOS涓婅繍琛岀殑鍙墽琛屾枃浠躲

鍙互鐢ㄤ笅闈㈢殑鍛戒护锛
pyinstaller -Fw E:\test\url_crawler.py
(-F 鏄墦鍖呮垚涓涓枃浠讹紝-w鏄笉鍑虹幇璋冭瘯绐楀彛锛屽洜涓烘垜鐨勫皬宸ュ叿閲屾湁GUI锛屾墍浠ヤ笉鐢ㄩ粯璁ょ殑璋冭瘯绐楀彛)


绗簩绉嶆柟寮忔槸浣跨敤cx_Freeze銆俢x_Freeze涔熸槸涓涓祦琛岀殑Python鎵撳寘宸ュ叿锛屽畠鍙互灏哖ython浠g爜鎵撳寘鎴愮嫭绔嬬殑鍙墽琛屾枃浠躲傚彧闇瑕佸湪鍛戒护琛屼腑杈撳叆"cxfreeze your_script.py --target-dir dist"锛屽氨鍙互鐢熸垚涓涓彲鍦╓indows銆丩inux鍜孧acOS涓婅繍琛岀殑鍙墽琛屾枃浠躲

绗笁绉嶆柟寮忔槸浣跨敤py2exe锛屽畠鏄竴涓笓闂ㄧ敤浜庡皢Python浠g爜鎵撳寘鎴怶indows鍙墽琛屾枃浠剁殑宸ュ叿銆傚彧闇瑕佸湪鍛戒护琛屼腑杈撳叆"python setup.py py2exe"锛屽氨鍙互鐢熸垚涓涓猈indows鍙墽琛屾枃浠躲

绗洓绉嶆柟寮忔槸浣跨敤py2app锛屽畠鏄竴涓笓闂ㄧ敤浜庡皢Python浠g爜鎵撳寘鎴怣acOS鍙墽琛屾枃浠剁殑宸ュ叿銆傚彧闇瑕佸湪鍛戒护琛屼腑杈撳叆"python setup.py py2app"锛屽氨鍙互鐢熸垚涓涓狹acOS鍙墽琛屾枃浠躲

绗簲绉嶆柟寮忔槸浣跨敤Nuitka锛屽畠鏄竴涓狿ython缂栬瘧鍣紝鍙互灏哖ython浠g爜缂栬瘧鎴怌++浠g爜锛岀劧鍚庢墦鍖呮垚鍙墽琛屾枃浠躲傚彧闇瑕佸湪鍛戒护琛屼腑杈撳叆"nuitka your_script.py"锛屽氨鍙互鐢熸垚涓涓彲鍦╓indows銆丩inux鍜孧acOS涓婅繍琛岀殑鍙墽琛屾枃浠躲

绗叚绉嶆柟寮忔槸缁撳悎浣跨敤Nuitka鍜宲yinstaller锛屽厛鐢∟uitka灏哖ython浠g爜缂栬瘧鎴怌++浠g爜锛岀劧鍚庡啀浣跨敤pyinstaller灏嗗叾鎵撳寘鎴愬彲鎵ц鏂囦欢銆傚彧闇瑕佸湪鍛戒护琛屼腑杈撳叆浠ヤ笅鍛戒护锛

1
2
nuitka --standalone your_script.py
pyinstaller your_script.spec
杩欏皢鐢熸垚涓涓彲鍦╓indows銆丩inux鍜孧acOS涓婅繍琛岀殑鍙墽琛屾枃浠躲

杩欎簺鏂规硶閮介潪甯哥畝鍗曟槗鐢紝鍙互鏍规嵁鑷繁鐨勯渶姹傞夋嫨閫傚悎鐨勬柟寮忔潵灏哖ython浠g爜鎵撳寘鎴愬彲鎵ц鏂囦欢锛屾彁楂樹唬鐮佺殑浣跨敤渚垮埄鎬с


浠ヤ笂灏辨槸Python浠g爜鎵撳寘鐢熸垚exe搴旂敤鐨勫叚绉嶆柟娉曠殑璇︾粏鍐呭锛屾洿澶氫俊鎭鍏虫敞OD浜戝叾瀹冪浉鍏虫枃绔狅紒



鏈枃URL锛http://www.odweb.cn/news_show.html?id=274