"ctypes\__init__.py", line 364, in __init__ OSError: [WinError 126] The specified module could not be found While running pyinstaller executable

Viewed 471

I am actually trying to make an executable from a .py file. I am using pandas, sklearn, pickle libraries and calling a ML model using pickle in the actual script. I have made a specfile to include the submodules of sklearn but still i am getting an error regarding ctype. I have searched a ton of discussion forums but cant seem to find any lead. please help me out. The error:

Traceback (most recent call last):
  File "site-packages\PyInstaller\loader\pyiboot01_bootstrap.py", line 174, in __init__
  File "ctypes\__init__.py", line 364, in __init__
OSError: [WinError 126] The specified module could not be found

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "apr_automated.py", line 29, in <module>
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
  File "c:\users\asus\appdata\local\programs\python\python37\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 623, in exec_module
    exec(bytecode, module.__dict__)
  File "site-packages\sklearn\__init__.py", line 78, in <module>
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
  File "c:\users\asus\appdata\local\programs\python\python37\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 623, in exec_module
    exec(bytecode, module.__dict__)
  File "site-packages\sklearn\_distributor_init.py", line 18, in <module>
  File "site-packages\PyInstaller\loader\pyiboot01_bootstrap.py", line 176, in __init__
__main__.PyInstallerImportError: Failed to load dynlib/dll 'D:\\Data Science Projects\\LTI-APR\\Latest app\\dist\\apr_automated\\sklearn\\.libs\\vcomp140.dll'. Most probably this dynlib/dll was not found when the application was frozen.
[1488] Failed to execute script apr_automated
PS D:\Data Science Projects\LTI-APR\Latest app\dist\apr_automated> 

The code snippet which might be the culprit:

model = pickle.load(open('grad_boost_better.pkl', 'rb'))

def req_features():
    i=0
    for x in data3.columns:
        if ':' in x:
            if data[x.split(sep=': ')[0]].str.contains(x.split(sep=': ')[1]).sum()>0:

                data3[x]=data[x.split(sep=': ')[0]]
        else:
            data3[x]=data[x]
        data3[x]=data3[x].map(dic)
        data3.fillna(value=0,inplace=True)
    return data3

req_features()
print('The Application name is: {}\nThe predicted output is: {}'.format(data['Application Name'].loc[0], model.predict(data3)))
0 Answers
Related