Python中py文件转exe

1.首先安装pip install pyinstaller


2.增加环境变量在path中添加scripts,例如c:\python36\scripts


3.在cmd中输入pyinstaller有显示内容,则代表success


4.切换到需要转exe的py文件夹下:shift +鼠标右键 选择打开cmd窗口


5.输入:pyintaller XXX.py即可转换


6.默认exe文件在dist下,执行时会自动弹出cmd窗口


ps:若不想弹出cmd窗口,pyinstaller -w XXX.py



若不想看见dist文件夹中一堆的内容,可以使用:
pyinstaller -F XXX.py 则在dist下只会生成一个XXX.exe




一个很酷的功能:
生成指定图标的exe,pyinstaller -i 'c:\users\123.ico' XXX.py
ico为图标

你可能感兴趣的:(Python)