pyinstaller执行脚本失败

时间:2018-06-25 05:55:21

标签: python pyinstaller

所以,我试图用脚本制作可执行文件。一切正常,没有任何错误,我可以用它制作可执行文件,并且可执行文件也正常工作。但是后来我添加了名为guessit的python模块。然后pyinstaller创建了exe,没有任何错误,但是当我运行exe时,它抛出了以下错误

Traceback (most recent call last):
  File "iconify.py", line 5, in <module>
  File "c:\python27\Lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 396, in load_module
    exec(bytecode, module.__dict__)
  File "site-packages\guessit\__init__.py", line 6, in <module>
  File "c:\python27\Lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 396, in load_module
    exec(bytecode, module.__dict__)
  File "site-packages\guessit\api.py", line 19, in <module>
  File "c:\python27\Lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 396, in load_module
    exec(bytecode, module.__dict__)
  File "site-packages\guessit\rules\__init__.py", line 11, in <module>
  File "c:\python27\Lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 396, in load_module
    exec(bytecode, module.__dict__)
  File "site-packages\guessit\rules\properties\episodes.py", line 14, in <module>
  File "c:\python27\Lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 396, in load_module
    exec(bytecode, module.__dict__)
  File "site-packages\guessit\rules\properties\title.py", line 11, in <module>
  File "c:\python27\Lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 396, in load_module
    exec(bytecode, module.__dict__)
  File "site-packages\guessit\rules\properties\language.py", line 10, in <module>
  File "c:\python27\Lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 396, in load_module
    exec(bytecode, module.__dict__)
  File "site-packages\babelfish\__init__.py", line 22, in <module>
  File "c:\python27\Lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 396, in load_module
    exec(bytecode, module.__dict__)
  File "site-packages\babelfish\country.py", line 21, in <module>
  File "site-packages\pkg_resources\__init__.py", line 1232, in resource_stream
  File "site-packages\pkg_resources\__init__.py", line 1479, in get_resource_stream
  File "site-packages\pkg_resources\__init__.py", line 1482, in get_resource_string
  File "site-packages\pkg_resources\__init__.py", line 1558, in _get
  File "c:\python27\Lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 479, in get_data
    with open(path, 'rb') as fp:
IOError: [Errno 2] No such file or directory: u'E:\\NEWFOL~1\\app\\dist\\Iconify\\babelfish\\data\\iso-3166-1.txt'
[9908] Failed to execute script iconify

为什么pyinstaller在可执行文件dist文件夹中搜索babelfish数据?我不知道这里出了什么问题,也不知道如何解决。请帮助

2 个答案:

答案 0 :(得分:0)

快速浏览-guessit库用于从视频文件名中获取有关视频的信息,包括允许视频进入的国家/地区。

Babelfish library用于处理国家和语言,并包括一个ISO 3166-1 text file,其中包含所有国家名称及其2个字符的代码。 Guessit包含Babelfish quite a few times,但是可执行文件的dist文件夹没有该ISO文本文件。我不确定pyinstaller的确切信息,但是您可以将上面的ISO文件复制到所需的文件夹中吗?

答案 1 :(得分:0)

在您的pyinstaller规范文件中:

from PyInstaller.utils.hooks import collect_data_files

a = Analysis(
  ...
  datas=[collect_data_files("babelfish")],

这将告诉pyinstaller包含来自babelfish软件包的数据,并将其包含在打包的可执行文件中。应该解决您的问题