I am trying to use Pyinstaller with django rest, it generates the .exe well but there is an error at the moment of executing the .exe, the error is this
ModuleNotFoundError: No module named 'rest_framework'
my question is how can I install the dependencies using Pyinstaller, or is there another way to do it.
This error ocurrs when you have dynamic imports in your code. In that case, pyinstaller don’t include those packages in exe file. In that case you can:
- Add unused import of those packages in your code
- Tell pyinstaller to include it
One file option does not change anything in running your code. If you’re create –onefile exe all files created by pyinstaller are packed to exe file, and unpacked to local temp every time when you run exe.
Other Possible Solutions are:
run your command from parent directory, i.e. instead of
c:\compilation\Gui>pyinstaller --name=gui manage.py
c:\compilation>pyinstaller --name=gui Gui\manage.py
Also Add runserver to the End of the File.
if still the Issue Persists, Then
pyinstaller –name=gui –exclude-module=PyQt4 –exclude-module=matplotlib –clean –win-private-assemblies manage.py runserver
Answered By – Syed Faizan