Imported module not found in PyInstaller
If you are using virtualenv you should use the "-p" or "--path='D:...'" option. Like this:
pyinstaller.exe --onefile --paths=D:\env\Lib\site-packages .\foo.py
What this does is generates foo.spec file with this pathex path
This sounds like a job for hidden imports (only available in the latest builds).
From the docs
a = Analysis(['myscript.py'], hiddenimports = ['_socket'], <and everything else>)
In my case, I had to delete all folders and files related to pyinstaller
in my directory, i.e. __pycache__
, build
, dist
, and *.spec
. I re-ran the build and the exe worked.