打包编译python脚本
一、生成requirements.txt依赖包文件方法
1、使用pip freeze命令生成
[root@localhost project]# pip freeze > requirements.txt
2、使用pipreqs命令生成
#安装pipreqs命令
[root@localhost project]# pip install pipreqs
#进入项目执行pipreqs命令
[root@localhost project]# pipreqs ./
二、安装requirements.txt文件中的依赖包
[root@localhost project]# pip install -r requirements.txt
三、安装编译命令pyinstaller
[root@localhost ]# pip install pyinstaller
四、 打包编译
[root@localhost ]# pyinstaller -F deploy.py --add-data 'config.yaml:.'
五、py2exe库安装
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple py2exe
注意:
1、打包之前请安装requirements.txt文件里的所有依赖包
2、打包添加配置文件时,在windows上使用--add-data 'config.yaml;.',在Linux上使用--add-data 'config.yaml:.'
参考链接
https://www.cnblogs.com/mywolrd/p/4756005.html
https://www.cnblogs.com/caijunchao/p/12845620.html
https://www.cnblogs.com/gopythoner/p/6337543.html
https://github.com/pex-tool/pex # 使用pex打包
https://www.toutiao.com/article/7565350759350305286/ # 使用py2exe库打包
浙公网安备 33010602011771号