简体   繁体   English

Windows和ZMQ上的CX_Freeze导入错误

[英]CX_Freeze import error on Windows and ZMQ

I've a python program that uses ZMQ. 我有一个使用ZMQ的python程序。 I want to Freeze it so everyone can use it as executable. 我想冻结它,以便每个人都可以将其用作可执行文件。 This is my setup.py 这是我的setup.py

import sys

from cx_Freeze import setup, Executable
includes = ["sip", "re", "zmq", "PyQt4.QtCore", "atexit", "zmq.utils.strtypes", "zmq.utils.jsonapi", "encodings.hex_codec"]

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

setup (
    name = "prueba",
    version = "0.1",
    description = "Esto es una prueba",
    options = {"build_exe" : {"includes" : includes }},
    executables = [Executable("Cliente.py", base = base)])

When I run this on Linux it works perfect and my program runs OK, but when I do so on Windows I get the Following Error when I execute the .exe file: 当我在Linux上运行它时,它可以完美运行,并且程序可以正常运行,但是当我在Windows上运行.exe文件时,出现以下错误:

from zmq.core import (constants, error, message, context,
File "ExtensionLoader_zmq_core_error.py", line 12, in <module>
ImportError: DLL load failed: The specified module cannot be found

Also, when CX_Freeze is working I can notice the following lines: Missing modules: ? 另外,当CX_Freeze工作时,我会注意到以下几行:缺少模块: zmq.core.Context imported from zmq.devices.basedevice ? 从zmq.devices.basedevice导入的zmq.core.Context? zmq.core.FORWARDER imported from zmq.devices.monitoredqueuedevice ? 从zmq.devices.monitoredqueuedevice导入的zmq.core.FORWARDER? zmq.core.QUEUE imported from zmq.devices.monitoredquedevice ? 从zmq.devices.monitoredquedevice导入的zmq.core.QUEUE? zmq.core.ZMQError imported from zmq.devices.monitoredquedevice 从zmq.devices.monitoredquedevice导入的zmq.core.ZMQError

I've been trying to figure out this problem for an hour or two, it seems it may be related with a DLL it should be importing and it isn't. 我一直在努力解决这个问题一两个小时,似乎它可能与应该导入的DLL有关,而与之无关。 Some DLL that ZMQ needs to work, but I cannot find which one is it. ZMQ需要工作的一些DLL,但我找不到它。

Fixed by adding: 通过添加以下内容进行修复:

['zmq','zmq.utils.garbage','zmq.backend.cython']

To the packages, then renaming zmq.libzmq.pyd to libzmq.pyd 对于软件包,然后将zmq.libzmq.pyd重命名为libzmq.pyd

You may have to explicitly add one or more modules to your includes. 您可能必须显式地将一个或多个模块添加到包含中。 If it IS a DLL issue though, I usually use Dependency Walker to figure it out. 如果这是一个DLL问题,我通常使用Dependency Walker来解决。 You can get it free here: http://www.dependencywalker.com/ 您可以在这里免费获得它: http : //www.dependencywalker.com/

It occasionally gave me a false positive, but overall it's almost always helped. 偶尔会给我带来误报,但总的来说,它几乎总是有帮助的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM