打包编译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:.'

注意:
      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

posted @ 2021-05-20 09:51  風£飛  阅读(122)  评论(0编辑  收藏  举报