Search code examples
djangopyinstaller

Pyinstaller and django Failed to colelct submodules


Here is my command:

pyinstaller --noconfirm --onedir --console --log-level "ERROR" --hidden-import "rest_framework.schemas" --hidden-import "django.contrib.gis.utils" --paths "C:/Users/a/Documents/GitHub/compute-local/backend/.env/Lib/site-packages" --additional-hooks-dir "C:/Users/a/Documents/GitHub/compute-local/backend/extra-hook" --hidden-import "djoser.urls" --paths "C:/Users/a/Documents/GitHub/compute-local/backend/.env/Lib/site-packages/djoser/urls" --paths "C:/Users/a/Documents/GitHub/compute-local/backend/.env/Lib/site-packages/rest_framework/schemas" --hidden-import "djoser" --hidden-import "rest_framework"  "C:/Users/a/Documents/GitHub/compute-local/backend/manage.py"

And here are the errors

WARNING: Failed to collect submodules for 'djoser.urls' because importing 'djoser.urls' raised: 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. 763 WARNING: Failed to collect submodules for 'rest_framework.schemas' because importing 'rest_framework.schemas' raised: 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.

Can someone help me navigate this issue?


Solution

  • I basically copied the Python libraries from the .env file into the PyInstaller on the same level as the other libraries there and it worked.

    I also copied the python DLLs into the folder.