【问题标题】:cx_freeze building a project to an .exe file, getting numpy import errorscx_freeze 将项目构建为 .exe 文件,出现 numpy 导入错误
【发布时间】:2017-10-04 15:33:49
【问题描述】:

我正在尝试将我的项目编译为 .exe 文件。

我在网上了解到 cx_freeze 是一个不错的选择。 所以我有这个 setup.py 脚本:

import sys
from cx_Freeze import setup, Executable

# Dependencies are automatically detected, but it might need fine tuning.
build_exe_options = {"packages": ["functions"], "excludes": ["tkinter"]}

# GUI applications require a different base on Windows (the default is for a
# console application).
base = None
if sys.platform == "win32":
    base = "Win32GUI"

setup(  name = "Bacteria Data Analysis",
    version = "0.1",
    description = "This program analyses data from experiments",
    options = {"build_exe": build_exe_options},
    executables = [Executable("main.py", base=base)])

它构建得很好:python setup.py build

但是当我尝试运行我的 .exe 程序时,我得到了这个错误:

它似乎与numpy有关,但无法弄清楚如何修复它......我已经安装和卸载了numpy,但不幸的是没有运气。

我在 cmd 中运行“python”的输出如下:

Python 3.6.1 |Anaconda custom (64-bit)| (default, May 11 2017, 13:25:24) 
[MSC v.1900 64 bit (AMD64)] on win32

【问题讨论】:

    标签: python numpy cx-freeze


    【解决方案1】:

    这就是我通常使用 numpy 处理我的 cx_freeze 应用程序的方式

    addtional_mods = ['numpy.core._methods', 'numpy.lib.format']
    
    packages = ["numpy"]
    options = {
        'build_exe': {
    
    
    
            'includes': addtional_mods,
            'packages':packages,
        },
    
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-07-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-07-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多