【问题标题】:Strange core_cy module import error while running cx_freeze built python executable运行 cx_freeze 构建的 python 可执行文件时出现奇怪的 core_cy 模块导入错误
【发布时间】:2015-12-02 17:43:19
【问题描述】:

我正在尝试将我的 Python 脚本导出到高性能集群(运行 CentOS 6),同时避免安装其他 Python 包的需要。我使用了一个虚拟 CentOS 6 环境,在该环境中安装了所有必需的软件包,以使用 cx_freeze 创建一个可执行文件,然后我可以将其传输到集群中执行。

我在使用 scipycx_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。但这并没有起到任何作用。

提前谢谢你!

【问题讨论】:

    标签: python centos6 cx-freeze


    【解决方案1】:

    经过一些额外的研究,我发现core_cyskimage 模块的一个模块。我继续将 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)])
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-02-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-12-24
      • 2012-10-14
      • 2020-12-21
      • 2023-03-06
      相关资源
      最近更新 更多