PyQT 打包成exe

环境:PyCharm windows10

  1. cmd打开命令行进入py文件所在目录
  2. 输入pyinstaller.exe -F -w 文件名.py
  3. 此时在该目录下会生成build和dist两个文件夹,在生成的dist文件夹下就会有一个exe文件。
  4. 可以复制该exe文件到其他地方,再将platforms文件复制到该目录下:
    在这里插入图片描述其中要注意的是这里的platforms文件来自PyQt5\Qt\plugins\platforms
    ,我电脑中的完整路径是
    E:\installation\Python\Lib\site-packages\PyQt5\Qt\plugins
    注意是在PyQt文件夹中(因为我们使用了PyQt),而不是mingw等地方。否则就会有错误:
    This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.
    PyQT 打包成exe_第1张图片

你可能感兴趣的:(python,qt)