python打包exe
一、安装pyinstaller
cmd命令安装
pip install pyinstaller
如果下载失败建议使用代理
(1)国内pip源:
清华:https://pypi.tuna.tsinghua.edu.cn/simple
阿里云:https://mirrors.aliyun.com/pypi/simple
中国科技大学 https://pypi.mirrors.ustc.edu.cn/simple
豆瓣:https://pypi.douban.com/simple
(2)临时使用
格式为:pip install -i 国内源网址 模块名
例如:pip install -i https://pypi.tuna.tsinghua.edu.cn/simple face_recognition
pip3 install -i https://pypi.douban.com/simple sqlalchemy
npm install -i https://pypi.douban.com/simple connect-multiparty
二、python程序打包(不带参数)
文件命名规范:不支持中文命令的python文件;
路径:建议路径中不带中文目录;
命令:pyinstaller -F 文件名(带后缀py)
#命令语法:pyinstaller -F 文件名(带后缀py)
#常用参数说明:
#–icon=图标路径
#-F 打包成一个exe文件
#-w 使用窗口,无控制台
#-c 使用控制台,无窗口
#-D 创建一个目录,里面包含exe以及其他一些依赖性文件
#pyinstaller -h 来查看参数
#将cmd的目录切换至(命令:cd 文件路径(注意空格))需要打包的py文件目录下:
#有命令窗口弹出
pyinstaller -F start.py
#无命令窗口弹出
pyinstaller -F -w start.py
#或者
pyinstaller -F start.py --noconsole
三、查看生成文件
build文件可以删掉
dist路劲下可执行文件