pyinstaller(windows)

  • 使用pip安装pyinstaller
    cmd: pip install pyinstaller
    pip基本不用单独装了,安装python时自动就装了,至少python3是这样,当然前提是安装时没把那个勾去掉。
    升级是这样的 pip install --upgrade pyinstaller
    同时,pyinstaller需要两个python模块支持:
    1.PyWin32或pypiwin32。使用pip安装pyinstaller时,如果电脑上没有安装这两个模块之一,它就会自动装上pypiwin32;
    2.pefile package。pip install pefile
    3.pip-Win package 也建议安装,但不是刚需。

  • 检测pyinstaller版本
    cmd:pyinstaller --version
    所以呢,输出版本号就证明安装成功。

  • 使用pyinstaller
    语法:pyinstaller [option] script [script...]|specfile
    1.最简单的就是在.py文件所在目录打开cmdpyinstaller myscript.py
    PyInstaller analyzes myscript.py and:
    Writesmyscript.specin the same folder as the script.
    Creates a folder build in the same folder as the script if it does not exist.
    Writes some log files and working files in the build folder.
    Creates a folder dist in the same folder as the script if it does not exist.
    Writes the myscript executable folder in the dist folder.
    dist文件夹下就是打包生成的exe文件及依赖。
    2.只打包生成一个文件pyistaller -F myscript.py
    此时dist下就是一个仅一个exe
    3.加个icon
    pyinstaller -F -i path\\icon.ico myscript.py

  • 一个warning
    WARNING: Can not get binary dependencies for file: C:\Windows\system32\api-ms-win-crt-heap-l1-1-0.dll
    虽然会打包成功,本地能运行,但是到了别人的电脑上就出现“无法定位程序输入点ucrtbase.terminate”这样的一个错误,同时指向这个dll。
    他这里也遇到了相同的问题暂时也没有解决。
    网上有人说客户端装个vc2015 Redistributable就行了(没尝试)
    哎,把warning的dll都抱出来,谁那缺谁自己考过去吧,应该是piinstaller自己的问题

  • 一个error
    Python 针对打包文件出现UnicodeDecodeError错误
    invalite start 巴拉拉
    网上有说是怪中文注释 出现中文字符串
    确实都是运行没问题 直接.py文件pyinstaller也没问题,对.pyc进行installer就有问题
    暂时就是在一个.py文件import这个.pyc然后pyinstaller这个.py

你可能感兴趣的:(pyinstaller(windows))