File execution error - No module named 'pywinauto'

Viewed 347

I am trying to run the .exe file that I have created from my .py file using pyinstaller. The script was written in Spyder (Python 3.8). The python version on my computer is 3.8 as well. The pyisntaller command runs without any errors and creates .exe file in the dist folder. However, when I try to run the generated .exe file, nothing hapens (apart from the black screen coming up with some "light speed" dispayed error).

I have decided to run it in CMD, so I can see what error is being produced...here is the message I get upon execution of .exe file:

Traceback (most recent call last):
   File "myScript.py", line 8, in <module>
ModuleNotFoundError: No module named 'pywinauto'
[13024] Failed to execute script myScript

The important thing to note, is that, while running the script directly from Spyder, it runs without any error.

I have tried installing pywinauto, using pip, but the error still persists. Any idea would be much appreciated!

1 Answers

Copy the following code as the first line of all your Python sources:

 print('__file__={0:<35} | __name__={1:<20} | __package__={2:<20}'.format(__file__,__name__,str(__package__)))

You have to make sure that for your main.py file:

__name__ is __main__ and __package__ must be None

You have to make sure that for your packages files:

__name__ is the name of the file and __package__ must be the name of the package

I fixed this issue reading this (Solution 1):

https://napuzba.com/a/import-error-relative-no-parent

Related