cx_freeze building a project to an .exe file, getting numpy import errors

霸气de小男生 提交于 2019-12-11 07:05:56

问题


I am trying to compile my project to an .exe file.

I've read around the internet that cx_freeze is a good choice for this. So I have this setup.py script:

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)])

And it builds just fine with: python setup.py build

But when I try to run my .exe program, I get this error:

It seems to be related to numpy somehow, but can't figure out how to fix it... I've installed and uninstalled numpy, but unfortunately without luck.

My output from running "python" in cmd, is as following:

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

回答1:


This is how I've typically gotten numpy to work with my cx_freeze applications

addtional_mods = ['numpy.core._methods', 'numpy.lib.format']

packages = ["numpy"]
options = {
    'build_exe': {



        'includes': addtional_mods,
        'packages':packages,
    },

}


来源:https://stackoverflow.com/questions/46568770/cx-freeze-building-a-project-to-an-exe-file-getting-numpy-import-errors

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!