简体   繁体   English

使用PyInstaller将.py转换为.exe时,如何修复丢失模块的问题?

[英]How to fix my problem with missing modules when converting .py to .exe with PyInstaller?

I started scraping in Python using Scrapy in PyCharm few weeks ago. 几周前 ,我开始在PyCharm中使用Scrapy在Python中进行拼抢 I found out about PyInstaller , which I used to make executable. 我发现了PyInstaller ,我曾经用它来制作可执行文件。 The problem is that whenever I run .exe file, it opens and closes instantly. 问题是每当我运行.exe文件时,它立即打开和关闭。

I found out that I get a lot of warnings when creating .exe like this ones bellow: 我发现在创建.exe时会收到很多警告,如下所示:

5666 WARNING: lib not found: api-ms-win-crt-heap-l1-1-0.dll dependency of c:\\users\\luka-pc\\appdata\\local\\programs\\python\\python37\\python37.dll 5666警告:未找到lib:c:\\ users \\ luka-pc \\ appdata \\ local \\ programs \\ python \\ python37 \\ python37.dll的api-ms-win-crt-heap-l1-1-0.dll依赖项
5756 WARNING: lib not found: api-ms-win-crt-locale-l1-1-0.dll dependency of c:\\users\\luka-pc\\appdata\\local\\programs\\python\\python37\\python37.dll 5756警告:未找到lib:c:\\ users \\ luka-pc \\ appdata \\ local \\ programs \\ python \\ python37 \\ python37.dll的api-ms-win-crt-locale-l1-1-0.dll依赖项
8482 WARNING: lib not found: api-ms-win-crt-runtime-l1-1-0.dll dependency of c:\\users\\luka-pc\\appdata\\local\\programs\\python\\python37\\DLLs_hashlib.pyd 8576 WARNING: lib not found: api-ms-win-crt-runtime-l1-1-0.dll dependency of c:\\users\\luka-pc\\appdata\\local\\programs\\python\\python37\\DLLs\\select.pyd 8684 WARNING: lib not found: api-ms-win-crt-heap-l1-1-0.dll dependency of c:\\users\\luka-pc\\appdata\\local\\programs\\python\\python37\\DLLs_bz2.pyd 8482警告:找不到lib:c:\\ users \\ luka-pc \\ appdata \\ local \\ programs \\ python \\ python37 \\ DLLs_hashlib.pyd的api-ms-win-crt-runtime-l1-1-0.dll依赖8576警告:找不到lib:c:\\ users \\ luka-pc \\ appdata \\ local \\ programs \\ python \\ python37 \\ DLLs \\ select.pyd的api-ms-win-crt-runtime-l1-1-0.dll依赖8684警告:找不到lib:c:\\ users \\ luka-pc \\ appdata \\ local \\ programs \\ python \\ python37 \\ DLLs_bz2.pyd的api-ms-win-crt-heap-l1-1-0.dll依赖项

Running .exe file through Command Prompt says that the Scrapy module is missing, tried to fix it by adding --paths parameter to PyInstaller command when creating .exe but didn't work. 通过命令提示符运行.exe文件表示缺少Scrapy模块,尝试通过在创建.exe时向PyInstaller命令添加--paths参数来修复它但无法正常工作。 I already tried reinstalling pyinstaller but no effects. 我已经尝试重新安装pyinstaller但没有效果。

I'd like to be able to run scraper from my PC and on other PC-s also. 我希望能够从我的PC和其他PC上运行刮刀。

if it works on your IDE then try to pack script to single package using below command 如果它适用于您的IDE,则尝试使用以下命令将脚本打包到单个程序包

pyinstaller --onefile myscript.py

It will include all the required libraries in the package. 它将包括包中的所有必需库。 Also update the libraries which available on machine, that will help you to include missing files/dll's 还要更新机器上可用的库,这将帮助您包含丢失的文件/ dll

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM