Search code examples
pythonscipycx-freeze

Error if scipy is frozen into an executable with cx-Freeze


at the moment I am facing a problem regarding scipy and cx-Freeze.

Windows 7 Enterprise (64-Bit);
Python 3.5.2|Anaconda 4.2.0 (64-bit);
scipy 0.18.1;
cx-Freeze 5.0.1;

I want to freeze a python script into an executable. Below you find the source code and the freeze script.

main.py

import scipy

if __name__ == '__main__':
    print('Test dirstribution methods!')

That's the main.py file.

setup.py

import sys
from cx_Freeze import *

packages = ['numpy']
excludes = ['tkinter']

distTest_Target = Executable(
    script = "main.py",
    base = "Console",
    shortcutName="distTest",
    targetName = "distTest.exe"
)

build_exe_options  = {
    "packages": packages,
    "excludes":excludes
}

setup(name='distTest',
    version='1.0.0',
    description='distTest (64-bit)',
    options = {"build_exe": build_exe_options},
    executables=[distTest_Target]
)

The build process executes without errors, but if I try to start the exe I get the following Error: Figure: Error during execution of exe

If I try to add 'scipy' to the package list like packages = ['numpy','scipy'] I get another error during the build process: Figure: scipy ImportError.

Has anybody an idea what is wrong there? Thank you in advance for your help!


Solution

  • Installing the latest version of Anaconda (4.3.1) and editing hooks.py in the cx_freeze package:

    finder.IncludePackage("scipy.lib")
    

    replaced by:

    finder.IncludePackage("scipy._lib")
    

    solved the problem.