我在尝试冻结vispy应用时遇到了问题。
这是错误:
cx_Freeze: Python error in main script
---------------------------
Traceback (most recent call last):
File "C:\Python34\lib\site-packages\cx_Freeze\initscripts\Console.py", line 27, in <module>
exec(code, m.__dict__)
File "console_example.py", line 14, in <module>
File "C:\Python34\lib\site-packages\vispy\scene\visuals.py", line 41, in __init__
subclass.__init__(self, *args, **kwargs)
File "C:\Python34\lib\site-packages\vispy\visuals\text\text.py", line 380, in __init__
self._font = self._font_manager.get_font(face, bold, italic)
File "C:\Python34\lib\site-packages\vispy\visuals\text\text.py", line 127, in get_font
self._fonts[key] = TextureFont(font, self._renderer)
File "C:\Python34\lib\site-packages\vispy\visuals\text\text.py", line 45, in __init__
self._kernel = np.load(op.join(_data_dir, 'spatial-filters.npy'))
File "C:\Python34\lib\site-packages\numpy\lib\npyio.py", line 369, in load
fid = open(file, "rb")
FileNotFoundError: [Errno 2] No such file or directory: '*snip*\\build\\exe.win32-3.4\\library.zip\\vispy\\io\\_data\\spatial-filters.npy'
我看到了这个并检查它引用的文件是否包含在library.zip中。它不是,所以我改变了我的cx_freeze setup.py看起来像这样:
import sys
from cx_Freeze import setup, Executable
build_exe_options = {"packages": ["pyglet", "vispy"],
"includes": ["vispy.app.backends._pyglet"],
"zip_includes": [("C:\\Python34\\Lib\\site-packages\\vispy\\io\\_data\\spatial-filters.npy",
"vispy/io/_data/spatial-filters.npy")]}
base = None
if sys.platform == "win32":
base = "Win32GUI"
setup(name = "Test",
version = "0.1",
description = "Test",
options = {"build_exe": build_exe_options},
executables = [Executable("console_example.py", base=base)])
现在_data中的spatial-filters.npy文件位于library.zip里面,但错误仍然存在。我还需要做什么?