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

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:

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

Upvotes: 1

Views: 596

Answers (1)

Gardener85
Gardener85

Reputation: 369

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,
    },

}

Upvotes: 1

Related Questions