简体   繁体   中英

Pyinstaller failed to execute script

So, I'm trying to make an executable out of an script. It was working all fine without any error and I could make executable with this and the executable was also working fine. But then I added the python module named guessit . Then pyinstaller created the .exe without any error but when I'm running the .exe it's throwing the following error :

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

Why pyinstaller is searching for babelfish data in the executable dist folder? I have no idea whats going wrong here and don't know how to solve this. Please help.

From a quick glance - the guessit library is used to get information about videos from video filenames, including the countries the video is allowed in.

The Babelfish library is for working with countries and languages and includes an ISO 3166-1 text file which is all the country names and their 2-character code. Guessit includes Babelfish quite a few times but the dist folder for the executable doesn't have that ISO text file. I'm not sure of the exact ins and outs of pyinstaller, but could you just copy the ISO file above into the folder it requires?

In your pyinstaller spec file:

from PyInstaller.utils.hooks import collect_data_files

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

This will tell pyinstaller to include data from package babelfish and include it inside the packaged executable. Should fix your problem

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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