环境:PyCharm windows10
- cmd打开命令行进入py文件所在目录
- 输入
pyinstaller.exe -F -w 文件名.py
- 此时在该目录下会生成build和dist两个文件夹,在生成的dist文件夹下就会有一个exe文件。
- 可以复制该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.