1đź‘Ť
What is your files layout? According to these pyinstaller
docs https://github.com/pyinstaller/pyinstaller/wiki/Recipe-Executable-From-Django there could be two solutions.
-
run your command from parent directory, i.e. instead of
c:\compilation\Gui>pyinstaller --name=gui manage.py
do
c:\compilation>pyinstaller --name=gui Gui\manage.py
-
try to add
import django.contrib.admin.apps
to yourmanage.py
and make sure it exists
1đź‘Ť
To fix the “ImportError: No module named django.contrib.admin.apps” problem you have to create a directory, let’s call it “your_project/other_hooks”.
Inside that directory create a file called hook-django.contrib.py with this content:
#!/usr/bin/python
# -*- coding: utf-8 -*-
from PyInstaller.utils.hooks import collect_submodules
hiddenimports = collect_submodules('django.contrib')
Now call pyinstaller in this way:
pyinstaller --name=yourProject --additional-hooks-dir=your_project\other_hooks your_project\manage.py
While you can use any name for the directory, the file name is mandatory, it has to be “hook-django.contrib.py”.
Hope this helps.
References:
https://github.com/pyinstaller/pyinstaller/wiki/Recipe-Executable-From-Django
https://github.com/pyinstaller/pyinstaller/issues/2332
https://pythonhosted.org/PyInstaller/hooks.html#how-a-hook-is-loaded
- [Answered ]-Django – how to restrict number of pages an unauthenticated user can view
- [Answered ]-Django: Having arbitrary file access models