0

I have written a small python script to understand how to build an executable using pyinstaller. the script is

import numpy
import scipy

from scipy.optimize import linear_sum_assignment
from scipy.spatial.distance import cosine
from scipy.sparse.csgraph import _validation  


value_cos = cosine(0.2, 0.8) * 0.5
print('\n cos value calculated using cosine', value_cos)
cost = numpy.array([[4, 1, 3], [2, 0, 5], [3, 2, 2]])   

ls_assign = linear_sum_assignment(cost)
print("\n ls_assignment value :", ls_assign)

I do not see any error when I build the executable but when I go to the dist directory and try to run the executable, I get the following error

Traceback (most recent call last):
  File "site-packages/PyInstaller/loader/rthooks/pyi_rth_pkgres.py", line 13, in <module>
  File "/home/puneet/miniconda3/envs/nuitka/lib/python3.7/site-packages/PyInstaller/loader/pyimod03_importers.py", line 623, in exec_module
    exec(bytecode, module.__dict__)
  File "site-packages/pkg_resources/__init__.py", line 85, in <module>
ModuleNotFoundError: No module named 'pkg_resources.py2_warn'
[210875] Failed to execute script pyi_rth_pkgres

I am not sure if I am missing any arguments while building the executable. Any help will be appreciated.

2 Answers 2

1

Thanks Vignesh for replying. I just sorted the error by adding

import pkg_resources.py2_warn

at the top of other imports. Now the executable is working fine.

Sign up to request clarification or add additional context in comments.

1 Comment

okay please mark the answer as solved so that everyone knows
0

try modifying this comment line 15 and add the below line for hidden import in the following file In python 38 Windows FIXED by add this line to Python38/Lib/site-packages/PyInstaller/hooks/hook-pkg_resources.py

#hiddenimports = collect_submodules('pkg_resources._vendor')
hiddenimports = collect_submodules('pkg_resources._vendor') + ['pkg_resources.py2_warn']

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.