前几天写了一个人脸表情分析的小程序,想用pyinstall打包成一个可以移植的小软件。因为之前用过pyinstall,所以这次使用同样的方法对我的程序进行打包:

【pyinstaller -F --icon=图标.ico 要打包的文件.py --noconsole】

其中【-F】参数表示打包后生成单一的文件。pyinstall还有其他的一些参数可供选择:

What to generate:

-F, --onefile

create a single file deployment

-D, --onedir

create a single directory deployment (default)

-o DIR, --out=DIR

create the spec file in directory. If not specified, and the current directory is Installer’s root directory, an output subdirectory will be created. Otherwise the current directory is used.

-n NAME, --name=NAME

optional name to assign to the project (from which the spec file name is generated). If omitted, the basename of the (first) script is used.

但是当我使用之前同样的方法打包完成后,也生成了一个exe程序,双击执行的时候,什么也没有发生。在pycharm中运行良好的程序,到exe就什么都没有了,最恐怖的是连报错都没有!!

这时,可以使用【-C】参数,生成控制台版本的exe程序。这样会在【dist】文件夹下生成一个以程序命名的文件夹,在这个文件夹中会有这个exe程序。

我们在控制台下执行这个程序,如果程序无法正常执行的话,会输出错误信息:

看来我的错误是因为无法打开这个dat文件,我想起来我在程序中用到了这个数据文件,可能打包的时候,pyinstall没有吧这个需要的依赖文件装进exe程序中。

这时一种方法是吧这个dat文件拷贝进这个exe所在的文件夹中。

另一种方法就是修改【spec】文件。

打开spec文件,在datas参数里面添加依赖文件的路径

然后重新打包这个spec文件:【pyinstall from_video.spec】即可。

最新文章

  1. 定制Eclipse IDE之功能篇(一)
  2. [No00003B]string格式的日期时间字符串转为DateTime类型
  3. SynchronousQueue应用
  4. HDU 4856
  5. console下纯字符实现的俄罗斯方块
  6. http://www.dayandeng.com/ 诈骗网站
  7. linux 命令grep
  8. ASP.NET控件Button (e.CommandArgument的使用方法)
  9. 删除顺序链表中重复的数 (一) leecode
  10. buffer busy wait
  11. AVC1与H264的差别
  12. DOM ISO - get current element's XPATH
  13. JavaScript 复制对象
  14. (1)wr703n刷openwrt智能控制--配置wifi
  15. .NET Core 中正确使用 HttpClient 的姿势
  16. testng报告-extentsReports使用-klov
  17. vue 中通过 ajax 获取数据时,如何避免绑定的数据中出现 property of undefined 错误
  18. sring引入mybatis
  19. 奋斗STM32V3版ADC例程
  20. ORACLE中使用DBMS_RANDOM去产生随机数

热门文章

  1. 矩阵乘法code
  2. spring-data-jpa中findOne与getOne的区别 getOne没数据 findOne有数据
  3. OAuth 2和JWT - 如何设计安全的API?
  4. Android——媒体库 相关知识总结贴
  5. Eclipse Unhandled event loop exception GC overhead limit exceeded
  6. SQL Server 数据库基础笔记分享(下)
  7. appium 后台运行shell脚本
  8. Python验证码识别 安装Pillow、tesseract-ocr与pytesseract模块的安装以及错误解决
  9. pycharm启动慢 –xms -xmx相关参数设置
  10. Goldengate:ERROR 180 encountered commit SCN that is not greater than the highest SCN already processed