由于stop_words,无法创建python可执行文件

时间:2018-03-04 07:18:27

标签: python pyinstaller py2exe stop-words

我创建了一个5_gui.py,我尝试用它来制作一个exe。问题是,一旦我运行pyinstaller --onefile 5_gui.py(在正确的目录中)并尝试运行5_gui.exe,我就会收到以下错误:

Traceback <most recent call last):
    File "5—gei.Py", line 4, in <module>
    File "<frozen importlib._bootstrap>", line 961, in _find_and_load
    File "<frozen importlib._bootstrap>", line 950, in _find_and_load_unlocked 
    File "<frozen importlib._bootstrap>", line 655, in _load_unlocked
    File "c:\users\nepheli\appdata\local\programs\python\python36-32\lib\site—packages\PyInstaller\loader\pyimod03_importers.py", line 631, in exec_module 
      exec<bytecode, module. dict )
    File "site—packages\stop_words\__init__.py", line 9, in <module> 
FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Users\\Nepheli\\App Data\\Local\\Temp\\_MEI78482\\stop_words\\stop—words\\languages.json'
[4272] Failed to execute script 5_gui

我在脚本中导入了stop_words以及许多其他库,因此我无法理解模块可能出现的问题。我搜索了目录以查看stop_words所在的位置,并且它并不是错误[Errno 2]消息所说的位置。

这是错误和gui的第一行。然而gui有点大,所以特定问题的唯一实质性包含是导入的库:

from tkinter import *
import os, re
from collections import Counter
import stop_words
import shutil

我还尝试了其他几个将.py变为.exe的模块,例如py2exeNSIShttp://pytoexe.com/,但我仍然遇到同样的错误。< / p>

有人可以帮我理解为什么会收到此错误吗?

1 个答案:

答案 0 :(得分:0)

Your .exe file is missing the languages.json file. It can't run without it.

So you may want to head back to pytoexe.com and retry while uploading both your .py file and your languages.json file on it, and change your code according to what's written on the website.