Cx_Freeze构建后,未从Scikit映像定义Name Compose

时间:2018-09-13 19:37:26

标签: exe cx-freeze scikit-image

我正在尝试通过Cx_Freeze构建exe,在构建之前python脚本运行没有问题。

在成功编译并构建了Cx_Freeze之后,我无法在模块cytoolz上加载NameError:找不到名称“ compose”的地方。

此错误似乎是由错误调用链之后的模块scikit-image引发的:

enter image description here

到目前为止,在遵循类似于该错误的潜在解决方法之后,我尝试卸载/重新安装cytoolz,然后进行hafarazi(https://github.com/conda/conda/issues/3441)建议的conda升级。但是,这没有成功。

我的setup.py:

from cx_Freeze import setup, Executable

# Dependencies are automatically detected, but it might need
# fine tuning.
# When using flask-sqlalchemy add sqlite3.dll to include_files

import os.path
import scipy
PYTHON_INSTALL_DIR = os.path.dirname(os.path.dirname(os.__file__))
print(PYTHON_INSTALL_DIR)
os.environ['TCL_LIBRARY'] = os.path.join(PYTHON_INSTALL_DIR, 'tcl', 'tcl8.6')
os.environ['TK_LIBRARY'] = os.path.join(PYTHON_INSTALL_DIR, 'tcl', 'tk8.6')


#This fix the issue where Scipy module _ni_support can't be properly imported during build.
includefiles_list=[]
scipy_path = os.path.dirname(scipy.__file__)
includefiles_list.append(scipy_path)


buildOptions = dict(
    packages = ['flask','requests','sys','Jinja2','idna','encodings', 'asyncio','numpy', 'engineio','eventlet'],
    excludes = [],
    include_files=['templates/', 'static/', scipy_path]
)

import sys
base = 'Win32GUI' if sys.platform=='win32' else None
# base = 'Console'

executables = [
    Executable('runserver.py', base=base)
]

setup(name='Test',
      version = '1.0',
      description = '',
      options = dict(build_exe = buildOptions),
      executables = executables)

#After build:
#rename Jinja folder with jinja if module jinja is not found error encoutnered

我的平台是: Windows 10 Python 3.6

是否有解决此问题的可能建议?

1 个答案:

答案 0 :(得分:0)

问题是(至少我猜是这样),“ compose”在cytoolz \ __ init__.py中定义不正确:

from .itertoolz import *

from .functoolz import *

from .dicttoolz import *

from .recipes import *

from .compatibility import map, filter

# from . import sandbox

from functools import partial, reduce

sorted = sorted

# Aliases
comp = compose #<-- HERE!

# Always-curried functions
flip = functoolz.flip = curry(functoolz.flip)
memoize = functoolz.memoize = curry(functoolz.memoize)

functoolz._sigs.update_signature_registry()

from ._version import __version__, __toolz_version__

显然有人认为使用from ... import *是个好主意。 我现在正在处理相同的问题,如果我找到解决方法,则会通知您。

编辑:通过浏览functoolz,我发现了compose。通过添加(在cytoolz\__init__.py中)来修复此错误

import functoolz as futo

并替换

comp = compose

使用

comp = futo.compose