简体   繁体   English

如果将scipy冻结到具有cx-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. 目前我正面临着关于scipy和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. 我想将python脚本冻结为可执行文件。 Below you find the source code and the freeze script. 您可以在下面找到源代码和冻结脚本。

main.py main.py

import scipy

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

That's the main.py file. 这是main.py文件。

setup.py 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 构建过程执行没有错误,但如果我尝试启动exe我得到以下错误: 图:执行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 . 如果我尝试将'scipy'添加到包列表中,如packages = ['numpy','scipy'] ,那么在构建过程中会出现另一个错误: 图:scipy ImportError

Has anybody an idea what is wrong there? 有谁知道那里有什么问题? Thank you in advance for your help! 预先感谢您的帮助!

Installing the latest version of Anaconda (4.3.1) and editing hooks.py in the cx_freeze package: 安装最新版本的Anaconda(4.3.1)并在cx_freeze包中编辑hooks.py:

finder.IncludePackage("scipy.lib")

replaced by: 取而代之:

finder.IncludePackage("scipy._lib")

solved the problem. 解决了这个问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM