简体   繁体   English

运行cx_freeze构建的python可执行文件时出现奇怪的core_cy模块导入错误

[英]Strange core_cy module import error while running cx_freeze built python executable

I am trying to export my Python script to a high performance cluster (running CentOS 6), while circumventing the need to install additional Python packages. 我试图将我的Python脚本导出到高性能集群(运行CentOS 6),同时避免了安装其他Python软件包的需要。 I use a virtual CentOS 6 environment onto which I installed all the required packages to create an executable using cx_freeze , which I can then transfer to the cluster for execution. 我使用一个虚拟的CentOS 6环境,在该环境中安装了所有必需的软件包,然后使用cx_freeze创建了一个可执行文件,然后可以将其传输到集群中以执行该文件。

I ran into some errors with scipy and cx_freeze that I now believe to be resolved (thanks to extensive documentation on this subject on StackOverflow). 我现在认为scipycx_freeze遇到了一些错误,这些错误现在可以解决了(这要归功于StackOverflow上有关此主题的大量文档)。

However, I immediately got another error that I don't understand. 但是,我立即遇到另一个我不理解的错误。 I can not find any information on the supposed module that is missing, nor on the error itself, let alone in combination with cx_freeze . 我找不到关于假定模块的任何信息,也找不到错误本身的信息,更不用说与cx_freeze结合使用cx_freeze

The following error is generated when I try to run the executable: 当我尝试运行可执行文件时,会生成以下错误:

ImportError: No module named core_cy

I use the following setup.py from the file to build the executable using cx_freeze: 我使用文件中的以下setup.py来使用cx_freeze构建可执行文件:

import sys
import scipy

from os import path

from cx_Freeze import setup, Executable

includefiles_list=[]
scipy_path = path.dirname(scipy.__file__)

includefiles_list.append(scipy_path)

# Dependencies are automatically detected, but it might need fine tuning.
build_exe_options = {"packages": ["os"], "include_files": includefiles_list}

# GUI applications require a different base on Windows (the default is for a
# console application).
base = None

setup(  name = "CD34Filter",
        version = "0.1",
        description = "CD34Filter Script",
        options = {"build_exe": build_exe_options},
        executables = [Executable("cd34_filter.py", base=base)])

I already tried adding the "excludes": ["core_cy"] option to build_exe_options . 我已经尝试过加入"excludes": ["core_cy"]选项build_exe_options But that didn't do anything. 但这没有任何作用。

Thank you in advance! 先感谢您!

After some additional research, I found out that core_cy is a module of the skimage module. 经过一些额外的研究,我发现core_cyskimage模块的模块。 I proceeded by including scikit-image into the package in the same manner I used to include the scipy . 我将scikit-image包含在包中的方式与scipy包含scipy方式相同。 This resolved the error and now my executable runs great! 这解决了错误,现在我的可执行文件运行良好! Hope this will be of use to anyone else. 希望这对其他任何人都有用。

import sys
import scipy
import skimage

from os import path

from cx_Freeze import setup, Executable

includefiles_list=[]
scipy_path = path.dirname(scipy.__file__)
skimage_path = path.dirname(skimage.__file__)

includefiles_list.append(scipy_path)
includefiles_list.append(skimage_path)

# Dependencies are automatically detected, but it might need fine tuning.
build_exe_options = {"packages": ["os"], "include_files": includefiles_list}

# GUI applications require a different base on Windows (the default is for a
# console application).
base = None

setup(  name = "CD34Filter",
        version = "0.1",
        description = "CD34Filter Script",
        options = {"build_exe": build_exe_options},
        executables = [Executable("cd34_filter.py", base=base)])

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM