I am working to convert my Django project to a .exe file using Pyinstaller. I want to be able to just click an icon and open the project in a browser. Here is my folder structure:
proj
__pycache__
proj
__pycache__
__init__.py
manage.py
Dashboard
__pycache__
__init__.py
urls.py
proj
__pycache__
__init__.py
settings.py
urls.py
wsgi.py
static_cdn
And here is my manage.py file:
# -*- coding: utf-8 -*-
import os
import sys
if __name__ == "__main__":
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "proj.settings")
print("here")
try:
from django.core.management import execute_from_command_line
except ImportError as exc:
raise ImportError(
"Couldn't import Django. Are you sure it's installed and "
"available on your PYTHONPATH environment variable? Did you "
"forget to activate a virtual environment?"
) from exc
import django.test
from html.parser import HTMLParser
execute_from_command_line(sys.argv)
Currently I cd to C:...\proj, then run pyinstaller --name=Dashboard proj/manage.py
. Then when I click on Dashboard.exe in C:...\proj\dist\Dashboard, an error comes up.
I'm not sure what is going wrong here. I think I may either have something wrong with my folder structure, or I may be calling the pyinstaller in the wrong folder. Any help is super appreciated!
Additional information:
- I am following directions from this tutorial on how to make a .exe
- A similar question suggested adding an
__init__.py
file to C:...\proj\proj, however this makes the pyinstaller function fail with the errorModuleNotFoundError: No module named 'proj.settings'
. - I followed the answer of this question in my manage.py file.