如果使用 cx-Freeze 将 scipy 冻结为可执行文件,则会出错
Error if scipy is frozen into an executable with 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;
我想将 python 脚本冻结为可执行文件。您可以在下面找到源代码和冻结脚本。
main.py
import scipy
if __name__ == '__main__':
print('Test dirstribution methods!')
那是 main.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]
)
构建过程执行无误,但如果我尝试启动 exe,我会收到以下错误:
Figure: Error during execution of exe
如果我尝试将 'scipy' 添加到软件包列表中,例如 packages = ['numpy','scipy']
,我在构建过程中会遇到另一个错误:Figure: scipy ImportError.
有人知道哪里出了问题吗?预先感谢您的帮助!
正在安装最新版本的 Anaconda (4.3.1) 并在 cx_freeze 包中编辑 hooks.py:
finder.IncludePackage("scipy.lib")
替换为:
finder.IncludePackage("scipy._lib")
解决了问题。
目前我遇到了关于 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;
我想将 python 脚本冻结为可执行文件。您可以在下面找到源代码和冻结脚本。
main.py
import scipy
if __name__ == '__main__':
print('Test dirstribution methods!')
那是 main.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]
)
构建过程执行无误,但如果我尝试启动 exe,我会收到以下错误: Figure: Error during execution of exe
如果我尝试将 'scipy' 添加到软件包列表中,例如 packages = ['numpy','scipy']
,我在构建过程中会遇到另一个错误:Figure: scipy ImportError.
有人知道哪里出了问题吗?预先感谢您的帮助!
正在安装最新版本的 Anaconda (4.3.1) 并在 cx_freeze 包中编辑 hooks.py:
finder.IncludePackage("scipy.lib")
替换为:
finder.IncludePackage("scipy._lib")
解决了问题。