1.安装pyinstaller pip3/2 install pyinstaller 2.打开代码路径的DOS窗口 3. 生成exe pyinstaller -Fw .\json_to_csv.py #不带黑框(命令提示符) pyinstaller -F .\json_to_csv.py #带黑框(命令提示符) -F 表示生成单个可执行文件 -w 表示去掉控制台窗口,这在GUI界面时非常有用。不过如果是命令行程序的话那就把这个选项删除吧! -p 表示你自己自定义需要加载的类路径,一般情况下用不到 -i 表示可执行文件的图标 4. 如果Python2和Python3都安装了pyinstaller,可以使用路径来打包 E:\SoftWare\python27\Scripts\pyinstaller.exe -F G:\EclipsePython27Workspa ces\RDTool\RDTool\cdrKLogAddTime1.pyE:\SoftWare\python36\Scripts\pyinstaller.exe -F G:\EclipsePython27Workspa ces\RDTool\RDTool\cdrKLogAddTime1.py