[Answered ]-Pyinstaller 3.2 with django 1.10.1

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.

  1. 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
    
  2. try to add import django.contrib.admin.apps to your manage.py and make sure it exists

  3. report bug

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

Leave a comment