Python Flask - 将服务器构建为可执行文件 (Py2exe)
Python Flask - Building the Server as Executable (Py2exe)
我有一个 flask 项目,一切似乎都运行良好。当使用 py2exe 构建包时,(目标服务器是 windows 服务器呃),可执行文件可以执行,但给我留下 ImportError: No module named 'jinja2.ext'
我有这个模块,当不从 .exe 执行时,网站工作正常,没有 ImportError
我在打包和交付方面还很陌生,不确定导致 .py -> .exe 转换中断的设置有什么问题。
Setup.py
from setuptools import setup, find_packages
import py2exe
NAME = "WorkgroupDashboard"
VERSION = "1.0"
setup(
name=NAME,
version=VERSION,
description="Provides real time ISIS connection data",
long_description="",
# Get strings from http://www.python.org/pypi?%3Aaction=list_classifiers
classifiers=[],
author="Test User",
author_email='',
url='',
license='Free',
packages=find_packages(exclude=['ez_setup', 'examples', 'tests']),
include_package_data=True,
zip_safe=False,
install_requires=[
'flask >= 0.10.1',
'SQLAlchemy>=0.6'
],
console=['DashboardBack.py']
)
想法是为了打开服务器,只需执行.exe。服务器上不会有 python。我正在使用 Python 3.4 64 位。
编辑:build cmd = python setup.py py2exe
看来,安装命令进入 py2exe optuons=[]
工作Setup.py
__author__ = ''
import sys
from glob import glob # glob will help us search for files based on their extension or filename.
from distutils.core import setup # distutils sends the data py2exe uses to know which file compile
import py2exe
data_files = []
setup(
name='WorkgroupDashboard',
console=['DashboardBack.py'], # 'windows' means it's a GUI, 'console' It's a console program, 'service' a Windows' service, 'com_server' is for a COM server
# You can add more and py2exe will compile them separately.
options={ # This is the list of options each module has, for example py2exe, but for example, PyQt or django could also contain specific options
'py2exe': {
'packages':['jinja2'],
'dist_dir': 'dist/test', # The output folder
'compressed': True, # If you want the program to be compressed to be as small as possible
'includes':['os', 'logging', 'yaml', 'flask', 'sqlalchemy'], # All the modules you need to be included, because py2exe guesses which modules are being used by the file we want to compile, but not the imports
}
},
data_files=data_files # Finally, pass the
)
我会将我的转换为 EXE 并通过主机进行部署。只需获得 "Auto Py To Exe" 申请。在本地下载。打开应用程序,插入项目位置,根据需要进行一些设置,然后单击 "Convert"。给你。 EXE 格式的烧瓶。无需 Python Interpreter.
即可随心所欲地插入插件
我有一个 flask 项目,一切似乎都运行良好。当使用 py2exe 构建包时,(目标服务器是 windows 服务器呃),可执行文件可以执行,但给我留下 ImportError: No module named 'jinja2.ext'
我有这个模块,当不从 .exe 执行时,网站工作正常,没有 ImportError
我在打包和交付方面还很陌生,不确定导致 .py -> .exe 转换中断的设置有什么问题。
Setup.py
from setuptools import setup, find_packages
import py2exe
NAME = "WorkgroupDashboard"
VERSION = "1.0"
setup(
name=NAME,
version=VERSION,
description="Provides real time ISIS connection data",
long_description="",
# Get strings from http://www.python.org/pypi?%3Aaction=list_classifiers
classifiers=[],
author="Test User",
author_email='',
url='',
license='Free',
packages=find_packages(exclude=['ez_setup', 'examples', 'tests']),
include_package_data=True,
zip_safe=False,
install_requires=[
'flask >= 0.10.1',
'SQLAlchemy>=0.6'
],
console=['DashboardBack.py']
)
想法是为了打开服务器,只需执行.exe。服务器上不会有 python。我正在使用 Python 3.4 64 位。
编辑:build cmd = python setup.py py2exe
看来,安装命令进入 py2exe optuons=[]
工作Setup.py
__author__ = ''
import sys
from glob import glob # glob will help us search for files based on their extension or filename.
from distutils.core import setup # distutils sends the data py2exe uses to know which file compile
import py2exe
data_files = []
setup(
name='WorkgroupDashboard',
console=['DashboardBack.py'], # 'windows' means it's a GUI, 'console' It's a console program, 'service' a Windows' service, 'com_server' is for a COM server
# You can add more and py2exe will compile them separately.
options={ # This is the list of options each module has, for example py2exe, but for example, PyQt or django could also contain specific options
'py2exe': {
'packages':['jinja2'],
'dist_dir': 'dist/test', # The output folder
'compressed': True, # If you want the program to be compressed to be as small as possible
'includes':['os', 'logging', 'yaml', 'flask', 'sqlalchemy'], # All the modules you need to be included, because py2exe guesses which modules are being used by the file we want to compile, but not the imports
}
},
data_files=data_files # Finally, pass the
)
我会将我的转换为 EXE 并通过主机进行部署。只需获得 "Auto Py To Exe" 申请。在本地下载。打开应用程序,插入项目位置,根据需要进行一些设置,然后单击 "Convert"。给你。 EXE 格式的烧瓶。无需 Python Interpreter.
即可随心所欲地插入插件