Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

File "PyInstaller/loader/pyimod03_importers.py", line 546, in exec_module, ModuleNotFoundError: No module named 'x'

EDIT

I'm trying to import algosec.models in a file inside the algobot package.

I've tried to add --hidden-import algosec, I've also tried to add the path before importing, using sys.path.append(./../algosec) this is the error message I get when I try to run the program:

Traceback (most recent call last):
  File "algobot_packer/algobot.py", line 2, in <module>
  File "PyInstaller/loader/pyimod03_importers.py", line 546, in exec_module
  File "algobot/cli/cli.py", line 3, in <module>
  File "PyInstaller/loader/pyimod03_importers.py", line 546, in exec_module
  File "algobot/microsoft_teams/mainloop.py", line 9, in <module>
  File "PyInstaller/loader/pyimod03_importers.py", line 546, in exec_module
  File "algobot/framework/configuration.py", line 34, in <module>
  File "PyInstaller/loader/pyimod03_importers.py", line 546, in exec_module
  File "algobot/framework/commands.py", line 22, in <module>
  File "PyInstaller/loader/pyimod03_importers.py", line 546, in exec_module
  File "algobot/framework/bot.py", line 4, in <module>
  File "PyInstaller/loader/pyimod03_importers.py", line 546, in exec_module
  File "algobot/framework/responses.py", line 9, in <module>
ModuleNotFoundError: No module named 'algosec'

the folder structure is:

  • algobot
    • algobot
    • algosec
    • algobot-packer
    • pyucwa

I'm using pyinstaller version 4.2 I didn't make any change in the code since the last time my executable file ran perfectly fine, but now I'm getting this error every time. the thing is - the folder 'algosec' is a subdirectory in my project, and it is noted in the pipfile and again, I didn't make any change in a while and tested it recently (last tested on July 8th)), therefore I believe that it's a dependency issue but not sure which or how to solve.

I've tried multiple changes that somehow worked on one run but when I tried to make these changes again it failed on other builds...

like image 569
Daniel Avatar asked Aug 26 '21 12:08

Daniel


2 Answers

You can use
--add-data "path_to_algobot:."
based on your system for windows use ; and for linux use :

It will explicitly add your algosec folder into the package.

like image 197
Deep Avatar answered Oct 20 '22 06:10

Deep


Apparently since I took the highest version of zeep and deprecated without giving a fixed version, it caused issues because of a newer release. I had to add them to setup.py of the algobot package which is the main package of the executable with a fixed version.

In addition I had to add a .egg file of the algosec package with --paths in order for pyinstaller to find it.

like image 1
Daniel Avatar answered Oct 20 '22 04:10

Daniel