我正在尝试将我的Python脚本导出到高性能集群(运行CentOS 6),同时避免了安装其他Python软件包的需要。我使用虚拟的CentOS 6环境安装了所有必需的软件包,使用cx_freeze
创建可执行文件,然后我可以将其传输到集群中执行。
我遇到了scipy
和cx_freeze
的一些错误,我现在认为这些错误已得到解决(感谢StackOverflow上关于此主题的大量文档)。
然而,我立即得到另一个我不明白的错误。我找不到任何关于假定模块缺失的信息,也没有关于错误本身的信息,更不用说与cx_freeze
结合使用了。
尝试运行可执行文件时生成以下错误:
ImportError: No module named core_cy
我使用文件中的以下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)])
我已尝试将"excludes": ["core_cy"]
选项添加到build_exe_options
。但那并没有做任何事情。
提前谢谢!
答案 0 :(得分:1)
经过一些额外的研究,我发现core_cy
是skimage
模块的一个模块。我继续将scikit-image包含在包中,其方式与我过去包含scipy
的方式相同。这解决了错误,现在我的可执行文件运行得很好!希望这对任何人都有用。
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)])