Search code examples
pythonpython-3.xdjangopyinstaller

Pyinstaller and Django any collect_submodules failed to import


This problem is new to me.

When using extra libraries, they cannot be incorporated into the pyinstaller build.

As an example I tried using --hidden-import, --collect-submodules and added a hook-djoser.urls.py file to try to solve one of the other problems. In this file I did this.

hook-djoser.urls.py in Lib\site-packages\PyInstaller\hooks

from PyInstaller.utils.hooks import collect_submodules
hiddenimports = collect_submodules('djoser.urls')
# pyinstaller --noconfirm --onedir --console --name "royalback"  "C:/Users/Shudf/royalback/manage.py"

And I can't make it work.

Would anyone be available to help?

Thanks

raise ImproperlyConfigured( django.core.exceptions.ImproperlyConfigured: Requested setting REST_FRAMEWORK, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings. collect_submodules: failed to import 'djoser.urls'!


Solution

  • Resolved with library auto-py-to-exe