使用pyinstaller从Python脚本生成exe文件

时间:2016-11-14 16:38:35

标签: python exe packaging

我有64位机器的python3.5。我有多个.py文件的项目,并有一个主文件使用同一目录中的其他.py文件运行整个代码。我想将它转换为.exe文件,以便我可以在没有安装python的系统上的代码。 Pyinstaller是我搜索的一个选项,我安装但不知怎的,当我运行命令

pyinstaller --onefile main.py

在命令提示符窗口中。它返回

failed to create process.

我不知道我是否正确使用它或它是不兼容的。但我肯定是正确安装的。任何使其工作的建议或如何以简单的方式使我的代码可执行到所有系统?感谢

因此,在纠正quotes problem后,我再次运行命令,并且有一个巨大的错误列表,我甚至都不认识:(我正在粘贴这些错误的一部分作为参考。

485 INFO: PyInstaller: 3.2
485 INFO: Python: 3.5.2
485 INFO: Platform: Windows-10-10.0.14393-SP0
501 INFO: wrote C:\Users\***********\PycharmProjects\MyfirstProject\ErrorCorrection.spec
501 INFO: UPX is not available.
523 INFO: Extending PYTHONPATH with paths
['C:\\Users\\***********\\PycharmProjects\\MyfirstProject',
 'C:\\Users\\***********\\PycharmProjects\\MyfirstProject']
523 INFO: checking Analysis
523 INFO: Building Analysis because out00-Analysis.toc is non existent
523 INFO: Initializing module dependency graph...
538 INFO: Initializing module graph hooks...
538 INFO: Analyzing base_library.zip ...
9993 INFO: running Analysis out00-Analysis.toc
10282 WARNING: lib not found: api-ms-win-crt-stdio-l1-1-0.dll dependency of c:\users\***********\appdata\local\programs\python\python35\python.exe
10367 WARNING: lib not found: api-ms-win-crt-math-l1-1-0.dll dependency of c:\users\***********\appdata\local\programs\python\python35\python.exe
10483 WARNING: lib not found: api-ms-win-crt-heap-l1-1-0.dll dependency of c:\users\***********\appdata\local\programs\python\python35\python.exe
10551 WARNING: lib not found: api-ms-win-crt-locale-l1-1-0.dll dependency of c:\users\***********\appdata\local\programs\python\python35\python.exe
10635 WARNING: lib not found: api-ms-win-crt-runtime-l1-1-0.dll dependency of c:\users\***********\appdata\local\programs\python\python35\python.exe
10852 WARNING: lib not found: api-ms-win-crt-stdio-l1-1-0.dll dependency of c:\users\***********\appdata\local\programs\python\python35\VCRUNTIME140.dll
10914 WARNING: lib not found: api-ms-win-crt-convert-l1-1-0.dll dependency of c:\users\***********\appdata\local\programs\python\python35\VCRUNTIME140.dll
10999 WARNING: lib not found: api-ms-win-crt-heap-l1-1-0.dll dependency of c:\users\***********\appdata\local\programs\python\python35\VCRUNTIME140.dll
11083 WARNING: lib not found: api-ms-win-crt-string-l1-1-0.dll dependency of c:\users\***********\appdata\local\programs\python\python35\VCRUNTIME140.dll
11152 WARNING: lib not found: api-ms-win-crt-runtime-l1-1-0.dll dependency of c:\users\***********\appdata\local\programs\python\python35\VCRUNTIME140.dll
12518 WARNING: lib not found: api-ms-win-crt-stdio-l1-1-0.dll dependency of c:\users\***********\appdata\local\programs\python\python35\python35.dll
12603 WARNING: lib not found: api-ms-win-crt-convert-l1-1-0.dll dependency of c:\users\***********\appdata\local\programs\python\python35\python35.dll
12672 WARNING: lib not found: api-ms-win-crt-math-l1-1-0.dll dependency of c:\users\***********\appdata\local\programs\python\python35\python35.dll
12741 WARNING: lib not found: api-ms-win-crt-process-l1-1-0.dll dependency of c:\users\***********\appdata\local\programs\python\python35\python35.dll
12839 WARNING: lib not found: api-ms-win-crt-environment-l1-1-0.dll dependency of c:\users\***********\appdata\local\programs\python\python35\python35.dll
12904 WARNING: lib not found: api-ms-win-crt-heap-l1-1-0.dll dependency of c:\users\***********\appdata\local\programs\python\python35\python35.dll
12989 WARNING: lib not found: api-ms-win-crt-string-l1-1-0.dll dependency of c:\users\***********\appdata\local\programs\python\python35\python35.dll
13058 WARNING: lib not found: api-ms-win-crt-conio-l1-1-0.dll dependency of c:\users\***********\appdata\local\programs\python\python35\python35.dll
13174 WARNING: lib not found: api-ms-win-crt-filesystem-l1-1-0.dll dependency of c:\users\***********\appdata\local\programs\python\python35\python35.dll
13258 WARNING: lib not found: api-ms-win-crt-locale-l1-1-0.dll dependency of c:\users\***********\appdata\local\programs\python\python35\python35.dll
13339 WARNING: lib not found: api-ms-win-crt-time-l1-1-0.dll dependency of c:\users\***********\appdata\local\programs\python\python35\python35.dll
13405 WARNING: lib not found: api-ms-win-crt-runtime-l1-1-0.dll dependency of c:\users\***********\appdata\local\programs\python\python35\python35.dll

最后在错误的错误列表之后说:

pywintypes.error: (5, 'EndUpdateResource', 'Access is denied.')

2 个答案:

答案 0 :(得分:0)

我也有这个问题,我使用PyQt5编写代码。代码是正确的,但是当我使用pyinstaller进行转换时,会出现错误,所以我找到了一种方法可以尝试it.use命令告诉位置。

  

pyinstaller --paths D:\ Python \ Lib \ site-packages \ PyQt5 \ Qt \ bin -F -w ***。py

答案 1 :(得分:0)

我在c:\上搜索=SUMPRODUCT(C2:C14,IF(NOT(ISERROR(MATCH(A2:A14,IF(B2:B14="Y",A2:A14,0),0))),1,0))

然后我将找到的所有api-ms-win-crt-*.dll文件复制到新文件夹api-ms-win-crt-*.dll

在我的make.bat中,我添加此行以展开c:\python\dlls

path

它有效