【问题标题】: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 之外,我还可以使用其他冻结程序来制作可执行文件吗??

任何帮助将不胜感激!

【问题讨论】:

    标签: python numpy cx-freeze python-3.6


    【解决方案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={'': ''},
              )
        

        【讨论】:

          猜你喜欢
          • 2019-09-16
          • 1970-01-01
          • 1970-01-01
          • 2019-03-25
          • 2021-06-24
          • 2021-11-23
          • 1970-01-01
          • 1970-01-01
          • 2023-01-30
          相关资源
          最近更新 更多