cx_freeze无法导入numpy

问题描述 投票:3回答:3

我的主py文件工作正常,但当我用cx_freeze冻结这个并且我尝试打开时,它发生错误而无法打开。它说:enter image description here

这是我的setup.py:

import os
from cx_Freeze import setup, Executable
build_exe_options = {"packages":["lxml","gzip","requests"]}

setup(  name = "name",
        version = "0.1",
        description = "description",
        options = {"build_exe": build_exe_options},
        executables = [Executable("file.py", icon=os.path.join("icon_64x64.ico"), base="Win32GUI")])

..

python python-3.x numpy pyqt cx-freeze
3个回答
2
投票

这对我来说对python 3.6有用:

build_exe_options = {"packages": ["os", "numpy"], "includes": ["numpy"]}
base = None
if sys.platform == "win32":
    base = "Win32GUI"

setup(name="Hello World",
      version="0.1",
      description="My GUI application!",
      options={"build_exe": build_exe_options},
      executables=[Executable("main.py", base=base)])

0
投票

我使用Python 3.6.1和cx_Freeze 5.1.1遇到了类似的问题。我的代码只导入了pandas,而pandas又试图导入因缺少依赖性而失败的numpy。但是,由于我的代码并没有直接尝试导入numpy,因此cx_Freeze没有通知我这种差异。

我在我的代码中强制使用import numpy,然后cx_Freeze适当地通知了我丢失的依赖项。在对这些进行故障排除后,我从我的代码中删除了import numpy,并且生成的exe工作正常。

也许在你的主要开头添加import numpy可以让你看到缺少的东西?


0
投票

这将有效:

在site-packages / numpy / core /中查找“_methods”(我的情况下的具体位置:C:\ ProgramFile \ Anaconda3 \ Lib \ site-packages \ numpy \ core)并将其复制到build / exe.win32-2.7 / lib / numpy的/型芯/

现在运行,它会起作用。

© www.soinside.com 2019 - 2024. All rights reserved.