pyinstaller灏哖ython鏂囦欢鎵撳寘鎴恊xe

缃戜笂鏈夋暀绋嬶紝涔熶笉澶嶆潅锛屼絾瀹炴垬涓鍒颁袱涓潙锛屽嵈鎼滀笉鍒拌В鍐虫柟妗堬紝鐒跺悗璇墦璇挒瑙e喅浜嗐��

鏂规硶涓�锛氱洿鎺ip pyinstaller

1銆佺敱浜庡凡缁忓畨瑁呬簡anaconda锛岃繍琛�-cmd锛岃緭鍏ip pyinstaller锛屽畨瑁呭畬pyinstaller

2銆佽繘鍏ョ洰鏍囪剼鏈墍鍦ㄧ殑鏂囦欢澶癸紙cd /dD:\py\渚涘簲鍟嗙粨绠楋級

3銆乸yinstaller -F temp.py锛屽ぇ姒傚嚑鍒嗛挓鍚庝細鍦ㄨ剼鏈墍鍦ㄧ殑鏂囦欢澶逛笅锛岀敓鎴恇uild銆乨ist涓や釜鏂囦欢澶癸紝鍜寈xxxx.spe鏂囦欢锛宔xe鏂囦欢鍦╠ist鐩綍涓嬶紝鍛藉悕涓簍emp.exe銆�

鐢熸垚闇�瑕佸嚑鍒嗛挓鏃堕棿锛屾垜鐢熸垚鐨別xe鏂囦欢鏈�200M澶氥��

鍙傛暟-F锛堟垨 -onefile锛� 浜х敓涓�涓枃浠剁敤浜庨儴缃诧紝灏辨槸鎵�鏈夊唴瀹归兘鎵撳寘杩沞xe浜嗭紝鍙杩欎竴涓猠xe鏂囦欢灏卞彲鎵ц銆傝繕鏈夊叾浠栧弬鏁帮紝鎴戦兘娌$敤杩囷紝璇疯胺姝屻��

鏂规硶浜岋紙鎺ㄨ崘锛夛細 鑷涓嬭浇pyinstaller锛屼笅杞界綉鍧�锛�http://www.pyinstaller.org/

1銆佹壘鍒板悎閫傝嚜宸盤ython鐗堟湰鐨勬渶鏂板畨瑁呭寘锛屼笅杞借В鍘嬪埌浠绘剰鐩綍锛屾瘮濡侱:\py\PyInstaller-3.2.1

2銆佸畨瑁卲ywin32锛岃嚜琛屾悳绱紙鎴戞病鍦ㄤ笉瀹夎涓嬭瘯杩囷紝鎹涓嶈鐢熸垚鐨別xe杩愯浼氭姤閿欙級

3銆佸皢鑷繁鍐欑殑py鏂囦欢锛坱emp.py锛夋嫹璐濆埌pyinstaller瑙e帇鐩綍D:\py\PyInstaller-3.2.1

4銆佹墦寮�cmd cd杩涘叆瑙e帇鍚庣殑鐩綍D:\py\PyInstaller-3.2.1锛岃繍琛屽懡浠� python pyinstaller.py -F temp.py

5銆佸湪鐩綍涓嬩細鐢熸垚涓�涓猼emp鐨勬枃浠跺す锛岄噷闈㈠瓨鏀� temp.spec鏂囦欢锛屼袱涓枃浠跺す锛坉ist锛宐uild锛夛紝鍙互杩愯鐨別xe鍒欐斁鍦�/dist/temp涓嬶紝鍛藉悕涓簍emp.exe銆�

鏂规硶浜屽悓鏍蜂笉鏀寔涓枃鍚嶇殑.py鏂囦欢銆�

闂涓�锛氭姤閿櫬燯nicodeDecodeError: 'gbk' codec can't decode byte 0x80 in position 184: illegal multibyte sequence

鍘熷洜锛歺xxxx.py鐨勫悕绉颁腑鍖呭惈浜嗕腑鏂囬�楀彿

瑙e喅鍔炴硶锛�.py鏂囦欢鍚嶅彲浠ヤ腑鏂囧悕锛屼絾瑕佸幓鎺変腑鏂囬�楀彿

闂浜岋細澶氫釜py鏂囦欢锛屼箣闂村瓨鍦ㄨ皟鐢ㄥ叧绯伙紝鎬庝箞鍔烇紵

瑙e喅鍔炴硶锛氬彧瑕佹妸涓绘枃浠舵墦鍖呭氨鍙互浜�

闂涓夛細鎶ラ敊 RecursionError: maximum recursion depth exceeded 锛屽ぇ姒傛剰鎬濇槸閫掑綊澶婧㈠嚭浜嗐��

鍘熷洜涓嶆槑锛屾悳绱㈠埌鐨勮娉昿ython闄愬埗鐨勬渶澶ч�掑綊娣卞害鏄�900锛屽湪Python寮�澶村姞

import sys

sys.setrecursionlimit(1000000)

鐨勬柟娉曪紝娌$敤銆�

瑙e喅鍔炴硶锛氭崲浜嗙浜屾柟娉曪紝灏辨病鏈夋姤杩欎釜閿欎簡銆�

鏂规硶浜岃櫧鐒剁箒鐞愶紝浣嗕技涔庝笉瀹规槗鍑洪敊銆�

鎴戠殑鐜锛�

Python 3.5.2 |Anaconda 4.2.0 (64-bit)| (default, Jul聽聽5 2016, 11:41:13) [MSC v.1900 64 bit (AMD64)] on win32

PyInstaller: 3.2.1

灏忔妧宸э細

涓轰簡闃叉exe澶栨硠锛屽彲浠ュ姞涓瘑鐮侊紝鍦≒ython寮�澶村鍔犱唬鐮佸涓�

while True:

user_password = input('Please input your password:')

if user_password == '20170611':

print('Thanks for login!')

print('寮�濮嬭繍琛�')

break

else:

print('Your password is wrong!')

print('Please input again!')

PS锛氭渶鍚庢劅璋㈡煇浣嶈�侀粍鐨勬寚瀵�

你可能感兴趣的:(pyinstaller灏哖ython鏂囦欢鎵撳寘鎴恊xe)