【发布时间】:2018-04-20 14:53:26
【问题描述】:
我正在使用 Pyinstaller 将我的 Django 项目转换为 .exe 文件。我希望能够只单击一个图标并在浏览器中打开项目。这是我的文件夹结构:
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
这是我的 manage.py 文件:
# -*- 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)
目前我 cd 到 C:...\proj,然后运行 pyinstaller --name=Dashboard proj/manage.py。然后当我点击C:...\proj\dist\Dashboard中的Dashboard.exe时,出现错误。
我不确定这里出了什么问题。我想我的文件夹结构可能有问题,或者我可能在错误的文件夹中调用了 pyinstaller。任何帮助都非常感谢!
附加信息:
- 我正在遵循this tutorial 的指示,了解如何制作 .exe
-
similar question 建议将
__init__.py文件添加到 C:...\proj\proj,但这会导致 pyinstaller 函数失败并出现错误ModuleNotFoundError: No module named 'proj.settings'。 - 我在 manage.py 文件中遵循了this question 的答案。
【问题讨论】:
标签: python django executable pyinstaller