cx_freeze将项目构建到.exe文件,出现numpy导入错误 [英] cx_freeze building a project to an .exe file, getting numpy import errors
问题描述
我正在尝试将项目编译为.exe文件。
I am trying to compile my project to an .exe file.
我在互联网上读到cx_freeze是一个不错的选择。
所以我有这个setup.py脚本:
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)])
它的构建方式很好:python setup.py build
And it builds just fine with: python setup.py build
但是当我尝试运行我的.exe程序时,出现此错误:
But when I try to run my .exe program, I get this error:
它似乎与numpy有关,但无法弄清楚如何解决它...我已经安装并卸载了numpy,但不幸的是没有运气。
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.
我在cmd中运行 python的输出如下:
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
推荐答案
这通常是让numpy与我的cx_freeze应用程序一起工作的方式
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,
},
}
这篇关于cx_freeze将项目构建到.exe文件,出现numpy导入错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!