Skip to content
Advertisement

Django Pyinstaller .EXE gives me ModuleNotFoundError: No module named ‘app.urls’

I am trying to run a Django project using an EXE file compiled using Pyinstaller. But when I run the compiled .EXE file using this command I get ModuleNotFoundError: No module named 'app.urls' and another OsError: [WinError 123]. I will explain how I setup this stuff later.

Here is the full error when I run the .EXE file:

JavaScript

First I installed Pyinstaller and other dependencies using the commands:

JavaScript

Then I installed OSGeo4W64 on my Windows 10 machine for GDAL.

I added this in settings.py:

JavaScript

I also generated a spec file using this command:

JavaScript

And this is the generated manage.spec: (I added in datas the templates folder but it didn’t work…)

JavaScript

Then I generated the project using this command:

JavaScript

Also I edited libgdal.py to have the following:

JavaScript

Here is my main urls.py:

JavaScript

And here is INSTALLED_APPS:

JavaScript

Please help!!!

Advertisement

Answer

I able to fix this problem…

Here is what I have done:

  1. Generate spec file using pyi-makespec dj/manage.py
  2. Add app.urls in hiddenimports such as hiddenimports=['app.urls',],
  3. Use this command instead pyinstaller manage.spec

Finally!!!

Advertisement