'ModuleNotFoundError pyinstaller

I have my python script as "vrProcessSpecsForA0.py"

# %% imports
import os
import re
import pandas as pd
from pathlib import Path
from img.core.cloud import StagedImage, Stager, BasicImage
from img.dev.vr import VRSrc
from img.engine.vr_processors import roughness_processor
from img.engine.vr_processors import ripple_processor
from img.engine.vr_mlc_defect import MeanLocalCurvatureProcessor
from img.engine.vr_mechanical_stress import MechanicalStressProcessor
from img.util.img_util import normalize_255
from metrics_pb2 import MetricsProto
from basic_pb2 import Region

# Body of my code commented out

I am executing my python codes in a virtual environment on Linux and the code runs properly in vscode IDE. Now I try to make an exe file from it using the command below in the terminal:

(pvenv) marablu@LT-HZ9Q5J3:~/pylib-img/local_tests$ pyinstaller --onedir vr_ProcessSpecsForA0.py
24 INFO: PyInstaller: 5.0.dev0
24 INFO: Python: 3.8.10
29 INFO: Platform: Linux-5.10.16.3-microsoft-standard-WSL2-x86_64-with-glibc2.29
29 INFO: wrote /home/marablu/pylib-img/local_tests/vr_ProcessSpecsForA0.spec
52 INFO: UPX is not available.
52 INFO: Extending PYTHONPATH with paths
['/home/marablu/pylib-img/local_tests']
...
...
...
33384 INFO: Building PKG (CArchive) vr_ProcessSpecsForA0.pkg completed successfully.
33385 INFO: Bootloader /home/marablu/pvenv/lib/python3.8/site-packages/PyInstaller/bootloader/Linux-64bit-intel/run
33385 INFO: checking EXE
33386 INFO: Rebuilding EXE-00.toc because pkg is more recent
33386 INFO: Building EXE from EXE-00.toc
33388 INFO: Copying bootloader EXE to /home/marablu/pylib-img/local_tests/build/vr_ProcessSpecsForA0/vr_ProcessSpecsForA0
33388 INFO: Appending PKG archive to custom ELF section in EXE
33412 INFO: Building EXE from EXE-00.toc completed successfully.
33417 INFO: checking COLLECT
WARNING: The output directory "/home/marablu/pylib-img/local_tests/dist/vr_ProcessSpecsForA0" and ALL ITS CONTENTS will be REMOVED! Continue? (y/N)y
On your own risk, you can use the option `--noconfirm` to get rid of this question.
68431 INFO: Removing dir /home/marablu/pylib-img/local_tests/dist/vr_ProcessSpecsForA0
68534 INFO: Building COLLECT COLLECT-00.toc
68971 INFO: Building COLLECT COLLECT-00.toc completed successfully.
(pvenv) marablu@LT-HZ9Q5J3:~/pylib-img/local_tests$ cd dist/vr_ProcessSpecsForA0
(pvenv) marablu@LT-HZ9Q5J3:~/pylib-img/local_tests/dist/vr_ProcessSpecsForA0$ ./vr_ProcessSpecsForA0
Traceback (most recent call last):
  File "vr_ProcessSpecsForA0.py", line 6, in <module>
ModuleNotFoundError: No module named 'img'
[23291] Failed to execute script 'vr_ProcessSpecsForA0' due to unhandled exception!
(pvenv) marablu@LT-HZ9Q5J3:~/pylib-img/local_tests/dist/vr_ProcessSpecsForA0$

I added path1="/home/pylib-img/img" pathex['path1']

in the spec file and rebuilt the exe using "pyinstaller vr_ProcessSpecsForA0.spec" but did not help.

Any suggestion on how to solve this issue? Also, please do not recommend links that are not exactly tackling this issue. I have gone through almost all of them and none has solved the issue.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source