I am creating a standalone exe file with pyinstaller but I get the 'modulenotfound' error when I try to run it. It cannot locate the PIL module even though it is in the same 'site-packages' folder as all my other modules. How do I tell it where the PIL module is?
I have tried the following flags in my cmd line when using pyinstaller, none of them worked:
--hidden-import=Pillow
--hidden-import='PIL'
--hidden-import='Pillow'
My script uses the following line of code in regards to the PIL module:
from PIL import Image, ImageTk
Everything works fine in the script, it is only when I use pyinstaller that I have a problem.
I found a solution: I had to install pyinstaller within the PyCharm terminal, then I had to run pyinstaller within the PyCharm terminal as well using
pyinstaller --onefile -w "foo.py"
I was previously running a cmd right from my file directory outside of PyCharm and running pyinstaller there, but running pyinstaller inside PyCharm works.