我需要将一个(相当简单的)django应用程序打包到Windows上的独立可执行文件中。 py2exe失败后(我真的不明白为什么每个人都推荐它为django,这似乎是非常复杂的设置)我试过pyinstaller 。 它没有抱怨打包应用程序,但如果我尝试使用myapp.exe runserver localhost:8000运行服务器myapp.exe runserver localhost:8000运行它,我收到以下错误:
Traceback (most recent call last): File "<string>",line 5,in <module> File "c:python27libsite-packagesPyInstaller-2.1-py2.7.eggPyInstallerloaderpyi_importers.py",line 270,in load_ module exec(bytecode,module.__dict__) File "...buildckout00-PYZ.pyzdjango.test",module.__dict__) File "...buildckout00-PYZ.pyzdjango.test.client",line 21,module.__dict__) File "...buildckout00-PYZ.pyzdjango.db",line 11,in <module> File "...buildckout00-PYZ.pyzdjango.conf",line 52,in __getattr__ File "...buildckout00-PYZ.pyzdjango.conf",line 45,in _setup django.core.exceptions.ImproperlyConfigured: Requested setting DATABASES,but settings are not configured. You must eith er define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings.
我的manage.py脚本如下所示:
#!/usr/bin/env python import os import sys import Cookie import django.test import HTMLParser from django.conf import settings if __name__ == "__main__": os.environ.setdefault("DJANGO_SETTINGS_MODULE","myapp.settings") from django.core.management import execute_from_command_line execute_from_command_line(sys.argv)
为什么不识别环境variables,我该如何解决这个问题?
在Windows上发送^ C到Pythonsubprocess对象
在c#中使窗口突出显示search
file:// <somewhere>和file:/// <somewhere>之间有什么区别?
Python / Tkinter窗口事件和属性
应用程序分段错误,仅在使用MinGW在Windows上编译时
(免费)在Windows上的文本编辑器与文件夹视图?
在Windows下运行jruby的rspectesting运行速度非常慢
我通过在行后面导入django.test来解决这个问题
os.environ.setdefault("DJANGO_SETTINGS_MODULE","myapp.settings")
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。