简体   繁体   English

Pyinstaller - Python exe 运行时显示错误“无法执行脚本 pyi_rth_nltk”

[英]Pyinstaller - Python exe when run shows error “Failed to execute script pyi_rth_nltk”

I have developed a simple software in python with GUI.我在 python 中开发了一个带有 GUI 的简单软件。 I'm actually working on Natural Language Processing and I've just put the whole NLP process in a GUI.我实际上正在研究自然语言处理,我刚刚将整个 NLP 过程放在 GUI 中。

I tried to convert the whole project to a exe file in python using Pyinstaller.我尝试使用 Pyinstaller 将整个项目转换为 python 中的 exe 文件。 I successfully converted it to an exe file but when I run it, it shows an error message something like this This is the image of my error我成功地将它转换为 exe 文件,但是当我运行它时,它会显示一条类似这样的错误消息这是我的错误的图像

I have already solved it but by using another way of converting py to exe which is the cx_Freeze.我已经解决了它,但是通过使用另一种将 py 转换为 exe 的方法,即 cx_Freeze。

I had the same issue earlier today and finally got it to work using the following software versions:我今天早些时候遇到了同样的问题,最后使用以下软件版本让它工作:

Python 3.6.8, nltk 3.5 and a dev version of pyinstaller: Python 3.6.8、nltk 3.5 和开发版 pyinstaller:

pip install https://github.com/pyinstaller/pyinstaller/archive/develop.zip

Additionally, I used scikit-learn version 0.21.1.此外,我使用了 scikit-learn 版本 0.21.1。

Few days back, I had the same problem while compressing to EXE.几天前,我在压缩到 EXE 时遇到了同样的问题。 This Problem generally occurs when PyInstaller failes to find Libraries and Modules to import to the directory.当 PyInstaller 找不到要导入目录的库和模块时,通常会出现此问题。 But I overcame this problem and the wise solution yet tedious method to do is mentioned below,但是我克服了这个问题,下面提到了明智的解决方案但繁琐的方法,

  1. Convert Python Scripts to EXE with console = True in the .spec file or to be simple, do not add --noconsole argument while converting using System Argmuents method.(execute GUI with CMD)在 .spec 文件中使用console = True.spec脚本转换为 EXE,或者简单地说,在使用 System Argmuents 方法进行转换时不要添加--noconsole参数。(使用 CMD 执行 GUI)

  2. After successfully building the file, go to respective directory (dist folder) and open command prompt成功构建文件后,go 到相应目录(dist 文件夹)并打开命令提示符

  3. Run the Exe file using Command Prompt.使用命令提示符运行 Exe 文件。

  4. Find the error message and rectify it correspondingly.找到错误信息并进行相应的纠正。 For example, consider the following Error Message, vcomp140.dll is missing from \\sklearn\\libs directory.例如,考虑以下错误消息,\\ vcomp140.dll \\sklearn\\libs目录中缺少 vcomp140.dll。

  5. At the end of this Error Message, you'll find Failed to load dynlib/dll , Therefore, find the file or program which is missing.在此错误消息的末尾,您会发现Failed to load dynlib/dll ,因此,找到丢失的文件或程序。 Say, Here we've .libs\\vcomp140.dll说,这里我们有.libs\\vcomp140.dll

  6. Find vcomp140.dll using window search bar in your C Drive.使用 C 驱动器中的 window 搜索栏查找vcomp140.dll

  7. Copy the specific file and paste in the directory(under "dist" folder) where the file is missing.复制特定文件并粘贴到文件丢失的目录(在“dist”文件夹下)。 Here, the directory is dist\\PyScriptToEXE\\sklearn\\.libs这里的目录是dist\\PyScriptToEXE\\sklearn\\.libs

MatplotlibDeprecationWarning:
The MATPLOTLIBDATA environment variable was deprecated in Matplotlib 3.1 and will be removed in 3.3.
  exec(bytecode, module.__dict__)
Traceback (most recent call last):
...
...
...
py3.7.egg\PyInstaller\loader\pyiboot01_bootstrap.py", line 169, in __init__
__main__.PyInstallerImportError: Failed to load dynlib/dll 'C:\\Users\\MOHAMM~1\\AppData\\Local\\Temp\\_MEI38242\\sklearn\\.libs\\vcomp140.dll'. Most probably this dynlib/dll was not found when the application was frozen.
[13968] Failed to execute script try
  1. Follow the steps again using CMD to eliminate each error.使用 CMD 再次执行这些步骤以消除每个错误。

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

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