目的:
使用pyinstaller将python打包成可执行文件(exe)
问题:
在命令行中,执行 pyinstaller -F D:\program learning\python\studentsystem\studentsystem.py,出现如下错误信息
![](https://img-blog.csdnimg.cn/20190928193250387.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dlaXhpbl80MjY5NjYyMg==,size_16,color_FFFFFF,t_70)
问题分析
pyinstaller -F D:\program learning\python\studentsystem\studentsystem.py
由于路径中存在空格,命令被解析为 pyinstaller -F D:\program 导致没有找到要打包的文件,这一点从图1中的最后一行
valueError: script 'D:\program' not found 可以看出来。(把D:\program当作要被打包的python脚本了)
解决方案
将脚本路径包含在一对双引号中,如下:
pyinstaller -F “D:\program learning\python\studentsystem\studentsystem.py”
验证效果
![](https://img-blog.csdnimg.cn/20190928194932960.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dlaXhpbl80MjY5NjYyMg==,size_16,color_FFFFFF,t_70)