ok, finally I could fix it I do not fully understand it but once I got rid of my __init__.py files in the directories of my app as well as in the other directory of myOtherModule it worked. I guess in order to better understand things I need to better understand the logic behind __init__.py and the import mechanism in Python itself.
Anyway I thought I post it here so it may be useful for someone else in a similar situation. Thanks Gernot Schreider schrieb am Donnerstag, 19. Dezember 2024 um 17:14:04 UTC+1: > I further tried to get around this issue and took the effort to replace in > my app the import statement > > import <myOtherModule> > with > from<myOtherModule> import x,y,z, .... > Again this works fine in VSCode environment. After > pyinstaller -c --onefile <myApp> > I get an .exe, which executes and terminates with the following error msg > ... > ImportError: cannot import name 'xyz' from <myOtherModule> > (C:\Users\myname\AppData\Local\Temp\_MEI260402\<myOtherModule>\__init__.pyc) > [PYI-24848:ERROR] Failed to execute script <myApp> due to unhandled > exception > > It seems that pyinstaller somehow finds myOtherModule but does not > properly import > it. The temporary directory is not available after program termination so > I cannot access the __init__.pyc file > > The directory name _MEIxxxx tells me that this is from pyinstaller. > > Can anyone shed some light on this please ? > > > > > Gernot Schreider schrieb am Mittwoch, 18. Dezember 2024 um 14:25:00 UTC+1: > >> Pyinstaller vers. 6.11.1 >> from a python app, which runs from within VSCode I try to generate .exe >> with >> >> pyinstaller -p >> C:\users\<myname>\AppData\Roaming\Python\Python311\site-packages >> -c >> --onefile .<mypythonapp.py >> It creates the .exe but when I run it the exe throws this error >> AttributeError: module <myOtherModule> has no attribute <xyz> >> >> <xyz> being a function, which is defined in <myOtherModule> >> >> I am importing another Python script in my app via >> import <myOtherModule> >> >> I suspected some problems with paths and tried various but did not >> succeed. >> It is puzzling as it did work a few monts ago, I have no clue which >> changes cause now this error. I did update pyinstaller but that did not >> help though. >> >> Any advice how to resolve is very welcome >> >> >> >> -- You received this message because you are subscribed to the Google Groups "PyInstaller" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion visit https://groups.google.com/d/msgid/pyinstaller/f8eed7d6-f28b-4009-9a1c-6b4104fa55edn%40googlegroups.com.
