首先需要将cmd或者PowerShell目录cd 跳转到py脚本所在目录,然后直接执行 Pyinstaller -F即可完成程序的打包,其中我们关心它有哪些常见参数:

输入参数的含义

  • -F 表示生成单个可执行文件

  • -w 表示去掉控制台窗口,这在GUI界面时非常有用。不过如果是命令行程序的话那就把这个选项删除吧!

  • -p 表示你自己自定义需要加载的类路径,一般情况下用不到

  • -i 表示可执行文件的图标

  • 不过顺序上有要求,如果想要修改默认图标,正确的写法是:Pyinstaller -F -w -i "ico文件完整路径" "py文件完整路径”,否则经常编译出错。
  • 如果编译报"UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 5650: invalid start byte",可尝试在powershell下输入:chcp 65001。
  • 常见报错如下:
  • 171 INFO: checking Analysis
    171 INFO: Building Analysis because out00-Analysis.toc is non existent
    171 INFO: Initializing module dependency graph...
    187 INFO: Initializing module graph hooks...
    187 INFO: Analyzing base_library.zip ...
    5538 INFO: running Analysis out00-Analysis.toc
    5553 INFO: Adding Microsoft.Windows.Common-Controls to dependent assemblies of final executable
      required by d:\program files\python35\python.exe
    6380 INFO: Caching module hooks...
    6380 INFO: Analyzing D:\photo.ico
    Traceback (most recent call last):
      File "D:\Program Files\python35\Scripts\pyinstaller-script.py", line 11, in <module>
        load_entry_point('PyInstaller==3.3.1', 'console_scripts', 'pyinstaller')()
      File "d:\program files\python35\lib\site-packages\PyInstaller\__main__.py", line 94, in run
        run_build(pyi_config, spec_file, **vars(args))
      File "d:\program files\python35\lib\site-packages\PyInstaller\__main__.py", line 46, in run_bu
        PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs)
      File "d:\program files\python35\lib\site-packages\PyInstaller\building\build_main.py", line 79
        build(specfile, kw.get('distpath'), kw.get('workpath'), kw.get('clean_build'))
      File "d:\program files\python35\lib\site-packages\PyInstaller\building\build_main.py", line 73
        exec(text, spec_namespace)
      File "<string>", line 16, in <module>
      File "d:\program files\python35\lib\site-packages\PyInstaller\building\build_main.py", line 21
        self.__postinit__()
      File "d:\program files\python35\lib\site-packages\PyInstaller\building\datastruct.py", line 16
        self.assemble()
      File "d:\program files\python35\lib\site-packages\PyInstaller\building\build_main.py", line 41
        priority_scripts.append(self.graph.run_script(script))
      File "d:\program files\python35\lib\site-packages\PyInstaller\depend\analysis.py", line 201, i
        self._top_script_node = super(PyiModuleGraph, self).run_script(pathname)
      File "d:\program files\python35\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py",
    t
        contents = fp.read() + '\n'
      File "d:\program files\python35\lib\codecs.py", line 321, in decode
        (result, consumed) = self._buffer_decode(data, self.errors, final)
    UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 5650: invalid start byte

使用Pyinstaller打包python py文件注意事项的更多相关文章

  1. “failed to excute script xxx” PyInstaller 打包python程序为exe文件过程错误

    在使用PyInstaller打包python程序,打包命令为: pyinstaller -F -w -i manage.ico yourpyfile.py 顺便说一下几个参数的作用 -F:是直接生成单 ...

  2. pyinstaller打包python文件成exe(原理.安装.问题)

    py文件打包成exe文件的方式一共有三种:py2exe.PyInstaller和cx_Freeze 本文分四个步骤来详讲如何用PyInstaller将py文件打包成exe文件 1. PyInstall ...

  3. 使用pyinstaller打包Python应用,生成EXE执行文件

    在命令行中切换到要打包的程序所在目录,或者在程序目录打开命令行,直接输入下面的指令即可pyinstaller -F xxx.py pyinstaller -F -w -i manage.ico app ...

  4. PyInstaller 打包 python程序成exe

    pychaim下PyInstaller 打包 python程序 主题是使用PyInstaller 打包python时遇到一些问题以及解决方案,其中将要打包的程序是用tensorflow做的LSTM算法 ...

  5. PyInstaller打包python脚本的一些心得

    PyInstaller打包python脚本的一些心得 因为在公司经常要帮同事做一个从excel表格中提取出需要的内容的重复工作,比较繁琐还容易出错:于是就想着要写个程序,但是同事又不可能在电脑上也装上 ...

  6. 安装PyInstaller打包python

    安装PyInstaller 对于那些网络比较稳定,能够流畅使用pip源地址的用户,直接下面的命令就可以搞定: pip install pyinstaller 通常我们会下载源码包,然后进入包目录,执行 ...

  7. 运行 python *.py 文件出错,如:python a.py

    运行 python *.py 文件出错,如:python a.py(下图) 原因:没有安装web.py 解决:下载并安装 网址:http://webpy.org/install#install  (h ...

  8. python用pyinstaller打包成exe文件

    版本为Python2.7 一.安装Pyinstaller 1.安装pywin32 下载安装文件:查找到跟自己适用的python版本及window系统版本匹配的pywin32,下载后安装  使用pip命 ...

  9. win7 32位用pyinstaller打包Python和相关html文件 成exe

    http://tieba.baidu.com/p/3060401749?traceid= 安装 pyinstaller 然后 第一步你的脚本里面要做相应处理,添加一个函数:def resource_p ...

随机推荐

  1. M - Sum

    XXX is puzzled with the question below: 1, 2, 3, ..., n (1<=n<=400000) are placed in a line. T ...

  2. HDOJ HDU 1850 Being a Good Boy in Spring Festival

    Description 一年在外 父母时刻牵挂 春节回家 你能做几天好孩子吗 寒假里尝试做做下面的事情吧 陪妈妈逛一次菜场 悄悄给爸爸买个小礼物 主动地 强烈地 要求洗一次碗 某一天早起 给爸妈用心地 ...

  3. Unable to cast object of type 'System.Int32' to type 'System.Array'.

    x 入职了新公司.最近比较忙...一看博客...更新频率明显少了...罪过罪过... 新公司用ASP.NET MVC 遇上一个错误: Unable to cast object of type 'Sy ...

  4. 泡泡一分钟:Exploiting Points and Lines in Regression Forests for RGB-D Camera Relocalization

    Exploiting Points and Lines in Regression Forests for RGB-D Camera Relocalization 利用回归森林中的点和线进行RGB-D ...

  5. Codeforces 670E - Correct Bracket Sequence Editor - [链表]

    题目链接:https://codeforces.com/contest/670/problem/E 题意: 给出一个已经匹配的括号串,给出起始的光标位置(光标总是指向某个括号). 有如下操作: 1.往 ...

  6. nowcoder 206A - Birthday - [最小费用最大流]

    题目链接:https://www.nowcoder.com/acm/contest/206/A 题目描述 恬恬的生日临近了.宇扬给她准备了一个蛋糕.正如往常一样,宇扬在蛋糕上插了n支蜡烛,并把蛋糕分为 ...

  7. [No0000123]WPF DataGrid Columns Visibility的绑定

    场景:根据配置文件显示DataGrid中的某些列. 问题:Columns集合只是DataGrid的一个属性,这个集合在逻辑树或视觉树中是看不到的,也不会继承DataContext属性. 方法一:对Da ...

  8. 理解套接字Socket

    Socket 在应用层和传输层之间的一个抽象层,它把TCP/IP层复杂的操作抽象为几个简单的接口供应用层调用以实现进程在网络中通信. 需要记住的知识点: 监听的 Socket 和真正用来传数据的 So ...

  9. vuex 的基本使用之Module

    Module 首先介绍下基本的组件化规则:你可以根据项目组件的划分来拆分 store,每个模块里管理着当前组件的状态以及行为,最后将这些模块在根 store 进行组合. const moduleA = ...

  10. 运维监控篇(2)_Zabbix简单的性能调优

    Zabbix是一款高性能的分布式监控报警系统.比如现在常见的家用台式机配置处理器I5-3470.内存4GB1600MHz.硬盘7200rpm就能够监控1000台左右的HOST,是的没错Zabbix就是 ...