python打包成exe,但執行exe報錯,求解。
1、pycharm pycharm-professional-2018.1.4.exe 已安裝 64位的。
2、python python-3.7.0.exe 已安裝32位的。
3、隨便寫了一個小程式,RUN沒有問題,程式碼如下:
#!/usr/bin/python
# -*- coding: utf-8 -*-
for i in range(1,5):
for j in range(1,5):
for k in range(1,5):
if(i!=k) and (i!=j) and (j!=k):
print (i,j,k)
4、使用inpystaller生成exe可執行檔案
操作命令:inpystaller -F C:\Users\T5000\PycharmProjects\untitled\asd.py
日誌如下:
C:\Users\T5000>pyinstaller -F C:\Users\T5000\PycharmProjects\untitled\asd.py
78 INFO: PyInstaller: 3.3.1
78 INFO: Python: 3.7.0
78 INFO: Platform: Windows-10-10.0.17134-SP0
78 INFO: wrote C:\Users\T5000\asd.spec
93 INFO: UPX is not available.
93 INFO: Extending PYTHONPATH with paths
['C:\\Users\\T5000\\PycharmProjects\\untitled', 'C:\\Users\\T5000']
93 INFO: checking Analysis
93 INFO: Building Analysis because out00-Analysis.toc is non existent
93 INFO: Initializing module dependency graph...
109 INFO: Initializing module graph hooks...
109 INFO: Analyzing base_library.zip ...
3999 INFO: running Analysis out00-Analysis.toc
3999 INFO: Adding Microsoft.Windows.Common-Controls to dependent assemblies of final executable
required by c:\users\t5000\appdata\local\programs\python\python37-32\python.exe
4358 WARNING: lib not found: api-ms-win-crt-process-l1-1-0.dll dependency of c:\users\t5000\appdata\local\programs\python\python37-32\python37.dll
4405 WARNING: lib not found: api-ms-win-crt-conio-l1-1-0.dll dependency of c:\users\t5000\appdata\local\programs\python\python37-32\python37.dll
5130 INFO: Caching module hooks...
5146 INFO: Analyzing C:\Users\T5000\PycharmProjects\untitled\asd.py
5146 INFO: Loading module hooks...
5146 INFO: Loading module hook "hook-encodings.py"...
5271 INFO: Loading module hook "hook-pydoc.py"...
5271 INFO: Loading module hook "hook-xml.py"...
5599 INFO: Looking for ctypes DLLs
5599 INFO: Analyzing run-time hooks ...
5614 INFO: Looking for dynamic libraries
6895 INFO: Looking for eggs
6895 INFO: Using Python library c:\users\t5000\appdata\local\programs\python\python37-32\python37.dll
6911 INFO: Found binding redirects:
[]
6911 INFO: Warnings written to C:\Users\T5000\build\asd\warnasd.txt
6973 INFO: Graph cross-reference written to C:\Users\T5000\build\asd\xref-asd.html
6989 INFO: checking PYZ
6989 INFO: Building PYZ because out00-PYZ.toc is non existent
6989 INFO: Building PYZ (ZlibArchive) C:\Users\T5000\build\asd\out00-PYZ.pyz
7646 INFO: Building PYZ (ZlibArchive) C:\Users\T5000\build\asd\out00-PYZ.pyz completed successfully.
7646 INFO: checking PKG
7646 INFO: Building PKG because out00-PKG.toc is non existent
7646 INFO: Building PKG (CArchive) out00-PKG.pkg
9505 INFO: Building PKG (CArchive) out00-PKG.pkg completed successfully.
9520 INFO: Bootloader c:\users\t5000\appdata\local\programs\python\python37-32\lib\site-packages\PyInstaller\bootloader\Windows-32bit\run.exe
9520 INFO: checking EXE
9520 INFO: Building EXE because out00-EXE.toc is non existent
9520 INFO: Building EXE from out00-EXE.toc
9520 INFO: Appending archive to EXE C:\Users\T5000\dist\asd.exe
9520 INFO: Building EXE from out00-EXE.toc completed successfully.
5、找到生成的exe,執行此exe
C:\Users\T5000\dist\asd.exe
6、CMD報錯
Fatal Python error: initfsencoding: unable to load the file system codec
zipimport.ZipImportError: can't find module 'encodings'
Current thread 0x00003370 (most recent call first):
求大神解決???????????