Help : Failed to execute script

41 views
Skip to first unread message

Tim Lee

unread,
Mar 26, 2020, 5:24:42 AM3/26/20
to PyInstaller
Python 3.8.1
Windows 10
pyinstaller 3.6

Traceback (most recent call last):
  File "wctest.py", line 9, in <module>
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  File "d:\users\worker\appdata\local\programs\python\python38\scripts\image2line\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 623, in exec_module
    exec(bytecode, module.__dict__)
  File "scripts\image2line\lib\site-packages\workalendar\__init__.py", line 6, in <module>
  File "scripts\image2line\lib\site-packages\pkg_resources\__init__.py", line 482, in get_distribution
  File "scripts\image2line\lib\site-packages\pkg_resources\__init__.py", line 358, in get_provider
  File "scripts\image2line\lib\site-packages\pkg_resources\__init__.py", line 901, in require
  File "scripts\image2line\lib\site-packages\pkg_resources\__init__.py", line 787, in resolve
pkg_resources.DistributionNotFound: The 'workalendar' distribution was not found and is required by the application
[660] Failed to execute script wctest
executeError.png
wctest.py

bwoodsend

unread,
Apr 16, 2020, 2:10:50 PM4/16/20
to PyInstaller
So it's this tiny bit here in workalendar's __init__ causing the issue. Namely that what it's trying to do doesn't work frozen.

I can give you this temporary monkey wrench fix. Replace your import of workalendar with:

# Define a fake pkg_resources that has the structure needed so as not
# not to raise an error in workalendar's __init__
class pkg_resources(object):
   
def get_distribution(package):
       
return Foo
   
class Foo:
    version
= None

# inject it into the module cache so that it is found rather than the original
import sys
sys
.modules["pkg_resources"] = pkg_resources

from workalendar.asia import Taiwan

# Clear up the mess we've made incase we need the real pkg_resources for something else.
del sys.modules["pkg_resources"]

But it's a very hacky fix. I'd raise an issue with workalendar and ask them to change their __init__.
pkg_resourses is a horrible dependency anyway because it takes so long to load and they are using
it to do something very minor.

Brénainn




Reply all
Reply to author
Forward
0 new messages