简体   繁体   English

python3&pyqt4&cx_freeze:没有名为'sip'的模块

[英]python3 & pyqt4 & cx_freeze: no module named 'sip'

I just recently learned some python & pyqt basics, and today i wanted to convert a program I made to exe. 我最近刚学了一些python&pyqt基础知识,今天我想将我制作的程序转换为exe。 I'm using python 3.4.1 and PyQt4 installed via binary installer (my system is 32-bit Windows 7 Enterprise, if it makes any difference). 我正在使用通过二进制安装程序安装的python 3.4.1和PyQt4(如果有任何区别,我的系统是32位Windows 7 Enterprise)。 So I found Cx_Freeze should be a viable tool for the job, but as for now, I have spent several hours trying to make it work. 因此,我发现Cx_Freeze应该是完成这项工作的可行工具,但是到目前为止,我已经花了几个小时试图使其工作。

I installed Cx_Freeze from this site (after installing it from pypi.python.org and getting some error considering modules; this version supposedly has a patch that fixed it), and this is (the current version of) my setup.py file: 我从此站点安装了Cx_Freeze(从pypi.python.org安装Cx_Freeze并在考虑模块问题时遇到了一些错误;此版本据说已修复了该补丁),这是我的setup.py文件(的当前版本):

import sys
from cx_Freeze import setup, Executable

build_exe_options = {"packages": ["re", "sip"]}

setup(
    name = "Project",
    version = "1.0",
    description = "desc",
    options = {'build_exe': build_exe_options},
    executables = [Executable("project.py", base = "Win32GUI")]
    )

So, when i run it in cmd ( python setup.py build ), it creates the build folder and everything, but when i try to run the project.exe inside I get this error message . 因此,当我在cmd( python setup.py build )中运行它时,它将创建build文件夹和所有内容,但是当我尝试在内部运行project.exe时,会收到此错误消息

Among other, I also had tried having "re" and "sip" in includes (instead of packages). 除其他外,我还尝试过在include(而不是软件包)中包含“ re”和“ sip”。 Also one of earlier versions had no specific options defined by me. 同样,较早的版本之一没有我定义的特定选项。 Also tried simply copying several other setup files I could find on the net, and so on - yet nothing worked. 也尝试过简单地复制我可以在网上找到的其他几个安装文件,依此类推-但没有任何效果。

Thanks in advance for any help :)) 在此先感谢您的帮助:))

Reposting as an answer: 重新发布作为答案:

This is a bug that will be fixed in the next version of cx_Freeze. 这是一个错误,它将在下一版本的cx_Freeze中修复。 When it can't parse a code file as Python syntax, it tries to treat it as a compiled library, but that's not necessarily true (eg PyQt includes some separate files for Python 2 and 3). 当它无法将代码文件解析为Python语法时,它会尝试将其视为已编译的库,但这不一定是正确的(例如PyQt包括一些针对Python 2和3的单独文件)。 In the meantime, the simplest way to work around it is to apply the fix manually to your installed cx_Freeze, as described in this comment . 同时,解决此问题的最简单方法是将修复程序手动应用到已安装的cx_Freeze,如本注释中所述

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

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