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.
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.
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']
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.