用pyexe把django应用打包成 windows上EXE可执行文件
续上文
把django应用 打包 发布成 可独立运行的桌面程序
1:下载必需的软件包
http://www.python.org/getit/releases/2.6/
https://www.djangoproject.com/download/
http://users.skynet.be/sbi/libxml-python/
http://julabs.me/blog/python/unable-to-find-vcvarsall-bat/ 解决 zop interface 安装出错问题
http://old.zope.org/Products/ZopeInterface/
http://twistedmatrix.com/trac/wiki/Downloads
http://pypi.python.org/pypi/Scrapy
http://www.pythonware.com/products/pil/
http://docs.cherrypy.org/stable/intro/install.html
2:编写setup.py
importpy2exe
importglob
importos
setup(
options={"py2exe":{"compressed":1,
"optimize":2,
"ascii":1,
"bundle_files":1,
"packages":["encodings"],
"excludes":["pywin","pywin.debugger","pywin.debugger.dbgcon","pywin.dialogs",
"pywin.dialogs.list","Tkconstants","Tkinter","tcl"],
}},
#thesearethedatafilesliketemplates,sitemediaandadminmedia
data_files=[(".",["soldemo.db"]),
("templates\\sol",glob.glob("templates\\sol\\*.*")),
("templates\\feeds",glob.glob("templates\\feeds\\*.*")),
("media\\files",glob.glob("media\\files\\sol_avatar.jpg")),
("media",glob.glob("media\\*.*")),
("media\\css",glob.glob("media\\css\\*.*")),
("templates\\admin",glob.glob("templates\\admin\\*.*")),
("templates\\admin\\auth\\user",glob.glob("templates\\admin\\auth\\user\\*.*")),
("templates\\admin_doc",glob.glob("templates\\admin_doc\\*.*")),
("templates\\widget",glob.glob("templates\\widget\\*.*")),
("templates\\registration",glob.glob("templates\\registration\\*.*")),
("media\\css",glob.glob("templates\\admin\\media\\css\*.*")),
("media\\js",glob.glob("templates\\admin\\media\\js\\*.*")),
("media\\img",glob.glob("templates\\admin\\media\\img\\*.*")),
],
zipfile=None,
console=['soldemo.py'],
)3: 打包 python -OO setup.py py2exe --b 2 --optimize 2
然后 到dist 目录下 运行EXE 打开浏览器 localhost:8000 测试 OK
参考:http://www.jjude.com/2008/04/make-your-django-application-as-a-stand-alone-desktop-application/