我正在尝试使用py2exe打包我的烧瓶网页应用程序。我的setup.py文件如下:
import sys
from glob import glob
from distutils.core import setup
import py2exe
import os
import numpy # to resolve error: libiomo5md.dll: No such file or directory
sys.argv.append('py2exe')
data_files = []
setup(
console=['run.py'],
options={
'py2exe': {
'packages':['jinja2'],
'bundle_files': 1,
'dll_excludes':['MSVCP90.dll', 'libzmq.pyd'],
'excludes': ['zmq.libzmq'],
'dist_dir': 'dist/test',
'compressed': True,
'includes':['zmq.backend.cython','os', 'logging', 'yaml', 'flask'],
}
},
data_files=data_files # Finally, pass the
)
我没有在我的应用程序中使用任何unittest,我可以创建我的可执行文件,但是当我尝试启动我的run.exe文件时,我收到以下错误:
Traceback (most recent call last):
File "run.py", line 1, in <module>
File "zipextimporter.pyc", line 82, in load_module
File "views.pyc", line 10, in <module>
File "zipextimporter.pyc", line 82, in load_module
File "forms.pyc", line 13, in <module>
File "zipextimporter.pyc", line 82, in load_module
File "wtforms_components\__init__.pyc", line 3, in <module>
File "zipextimporter.pyc", line 82, in load_module
File "wtforms_components\fields\__init__.pyc", line 24, in <module>
File "zipextimporter.pyc", line 82, in load_module
File "wtforms_components\fields\phone_number.pyc", line 1, in <module>
File "zipextimporter.pyc", line 82, in load_module
File "sqlalchemy_utils\__init__.pyc", line 1, in <module>
File "zipextimporter.pyc", line 82, in load_module
File "sqlalchemy_utils\aggregates.pyc", line 373, in <module>
File "zipextimporter.pyc", line 82, in load_module
File "sqlalchemy_utils\functions\__init__.pyc", line 20, in <module>
ImportError: No module named mock
在我的library.zip文件夹中,我有sqlalchemy文件夹和使用mock.pyc代码进行测试的子文件夹。另外在我的Python27 \ Lib \ site-packages \ sqlalchemy \ testing文件夹中,我有mock.py和mock.pyc代码。我的mock.py代码的内容如下:
from __future__ import absolute_import
from ..util import py33
if py33:
from unittest.mock import MagicMock, Mock, call, patch, ANY
else:
try:
from mock import MagicMock, Mock, call, patch, ANY
except ImportError:
raise ImportError(
"SQLAlchemy's test suite requires the "
"'mock' library as of 0.8.2.")
如果您能帮助我解决问题,我感谢您。