错误消息 Missing required dependencies, import error: Missing required dependencies ['numpy' ] when I tr

Posted

技术标签:

【中文标题】错误消息 Missing required dependencies, import error: Missing required dependencies [\'numpy\' ] when I try and freeze an executable【英文标题】:error message Missing required dependencies, import error: Missing required dependencies ['numpy' ] when I try and freeze an executable错误消息 Missing required dependencies, import error: Missing required dependencies ['numpy' ] when I try and freeze an executable 【发布时间】:2017-06-30 16:45:42 【问题描述】:

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

缺少必需的依赖项,导入错误:当我尝试冻结可执行文件时缺少必需的依赖项 ['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 之外,我还可以使用其他冻结程序来制作可执行文件吗??

任何帮助将不胜感激!

【问题讨论】:

【参考方案1】:

Lib/site-packages/numpy/core/中找到名为_methods的numpy子模块复制粘贴到build/exe.win64-3.6/numpy/core/.

【讨论】:

【参考方案2】:

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

【讨论】:

【参考方案3】:

这是我的 setup.py,我可以确认它适用于带有 tkinter、pandas 和 numpy 的应用程序的 CX_freeze。 Numpy 似乎确实是一个很难破解的。

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='': '',
      )

【讨论】:

以上是关于错误消息 Missing required dependencies, import error: Missing required dependencies ['numpy' ] when I tr的主要内容,如果未能解决你的问题,请参考以下文章

我正在尝试定义 LSTM 并收到错误“TypeError: add() missing 1 required positional argument: 'layer'”

Socket.io 安装抛出 Missing required argument 错误

xcode工程编译错误:missing required architecture i386 解决方法

GLSL 给出奇怪的错误:“#version required and missing”仅在 Mac 上

Django 中创建Model时报以下错误: TypeError: init() missing 1 required positional argument: ‘on_delete’

处理TypeError: testFunc() missing 1 required positional argument: 'self' -- 没有实例化对象的错误