错误消息缺少必需的依赖项,导入错误:缺少必需的依赖项[' numpy'当我尝试冻结可执行文件时

时间:2017-06-30 16:45:42

标签: python numpy cx-freeze python-3.6

我试图使用python 3.6制作可执行程序,我发现可以做到的唯一软件是cx_Freeze。但是每次运行时都会遇到问题" python setup.py build"在CMD中,我在尝试打开我的应用程序时遇到错误。

缺少必需的依赖项,导入错误:缺少必需的依赖项[' numpy'当我尝试冻结可执行文件时。

这是我的setup.py

import cx_Freeze
from cx_Freeze import setup
from cx_Freeze import Executable
import sys
import matplotlib
import pandas

import os

import os.path
PYTHON_INSTALL_DIR = os.path.dirname(os.path.dirname(os.__file__))
os.environ['TCL_LIBRARY'] = os.path.join(PYTHON_INSTALL_DIR, 'tcl', 'tcl8.6')
os.environ['TK_LIBRARY'] = os.path.join(PYTHON_INSTALL_DIR, 'tcl', 'tk8.6')

base = None

if sys.platform == 'win32':
    base = "Win32GUI"

executables = [cx_Freeze.Executable("EXE.py",icon = 'RomacLogo.ico', base=base)]

build_exe_options = {"packages": ["numpy"]}

cx_Freeze.setup(
    name = "DAGM",
    options = {"build.exe":{"packages":["tkinter", "matplotlib",'numpy', "numpy.lib.format", "pandas", "glob"], "include_files":["RomacLogo.ico"]}},
    version = "0.01",
    description = "Data Transfer and Analysis Application",
    executables = executables
)

除了cx_freeze ??

之外,还有其他我可以用来制作可执行文件的冻结程序吗?

任何帮助将不胜感激!

3 个答案:

答案 0 :(得分:1)

Lib / site-packages / numpy / core / 副本中找到名为_methods的numpy子模块并将其粘贴到 build / exe.win64-3.6 / numpy / core /

答案 1 :(得分:0)

RESOLVED-KINDA ...我在python 3.5.0中创建了一个虚拟环境,并且能够为python 3.5运行py-installer。无法让cx_Freeze工作,numpy依赖仍然是一个问题。

答案 2 :(得分:0)

这是我的setup.py,我可以确认它适用于带有tkinter,pandas和numpy的应用程序的CX_freeze。脾气暴躁绝对是一个很难解决的问题。

import sys
from cx_Freeze import setup, Executable
import os

build_exe_options = {"include_files": ["tcl86t.dll", "tk86t.dll"], "packages": ["numpy"]} 


base = None  
if sys.platform == "win32":  
    base = "Win32GUI"  


os.environ['TCL_LIBRARY'] = r'C:\Users\lyu\AppData\Local\Programs\Python\Python36\tcl\tcl8.6'
os.environ['TK_LIBRARY'] = r'C:\Users\lyu\AppData\Local\Programs\Python\Python36\tcl\tk8.6'

setup(
      name = "Fun Fun Fun",
      version = "1.0",
      description = "Fun Fun Fun",
      options = {"build_exe": build_exe_options},
      executables = [Executable("funfunfunfunfun.py", base = base)],
      package_dir={'': ''},
      )