解决python3.6中pyinstall打包失败的问题

环境:python 3.6  pyinstall

一开始用百度上的方法,直接执行python目录下的pyinstall.exe文件,很好用。

C:\WINDOWS\System32>C:\Users\hasee\AppData\Local\Programs\Python\Python36\Scripts\pyinstaller.exe F:\python_code_test\rename.py

后来用了几次就不行了。直接报错!如下:

95 INFO: PyInstaller: 3.3.1
95 INFO: Python: 3.6.3
97 INFO: Platform: Windows-10-10.0.16299-SP0
Traceback (most recent call last):
  File "C:\Users\hasee\AppData\Local\Programs\Python\Python36\Scripts\pyinstaller-script.py", line 11, in 
    load_entry_point('PyInstaller==3.3.1', 'console_scripts', 'pyinstaller')()
  File "C:\Users\hasee\AppData\Local\Programs\Python\Python36\lib\site-packages\PyInstaller\__main__.py", line 92, in run
    spec_file = run_makespec(**vars(args))
  File "C:\Users\hasee\AppData\Local\Programs\Python\Python36\lib\site-packages\PyInstaller\__main__.py", line 39, in run_makespec
    spec_file = PyInstaller.building.makespec.main(filenames, **opts)
  File "C:\Users\hasee\AppData\Local\Programs\Python\Python36\lib\site-packages\PyInstaller\building\makespec.py", line 378, in main
    specfile = open(specfnm, 'w')
PermissionError: [Errno 13] Permission denied: 'C:\\WINDOWS\\System32\\rename.spec'

查了许多资料后知道pyinstall对python3.6支持不够好,可以用开发板的pyinstall来解决问题。下载地址:https://github.com/pyinstaller/pyinstaller

下载解压后,通过cmd终端进入此文件夹内执行:

python setup.py install

然后终端执行(这是我是在pyinstall文件路径下执行的):

python pyinstaller.py -F F:\python_code_test\rename.py

常用的命令中间的参数说明:

-w指令:直接发布的exe应用带命令行调试窗口,在指令内加入-w命令可以屏蔽。
-F指令:注意指令区分大小写。这里是大写。使用-F指令可以把应用打包成一个独立的exe文件,否则是一个带各种dll和依赖文件的文件夹

生成文件的保存路径在终端可见,自己注意。

解决python3.6中pyinstall打包失败的问题_第1张图片


你可能感兴趣的:(python)