使用Twisted的pyinstaller导入错误

3

我尝试使用pyinstaller编译我的Python程序,命令如下:

pyinstaller.py -F zchat_server.py

并且收到了错误消息:

F:\workplace\Python\network-study\zchat\dist>zchat_server.exe

Traceback (most recent call last):
  File "<string>", line 2, in <module>
  File "D:\pyinstaller-2.0\PyInstaller\loader\iu.py", line 386, in importHook
    mod = _self_doimport(nm, ctx, fqname)
  File "D:\pyinstaller-2.0\PyInstaller\loader\iu.py", line 480, in doimport
    exec co in mod.__dict__
  File "F:\workplace\Python\network-study\zchat\build\pyi.win32\zchat_server\out
00-PYZ.pyz\twisted", line 53, in <module>
  File "F:\workplace\Python\network-study\zchat\build\pyi.win32\zchat_server\out
00-PYZ.pyz\twisted", line 37, in _checkRequirements
ImportError: Twisted requires zope.interface 3.6.0 or later: no module named zop
e.interface.

我是新手,我编译了我的zchat_view.py(使用wxPython),一切都很好。 但是对于Twisted,我感到困惑。希望得到解决。

4个回答

4

我对此进行了一些研究 - 看起来PyInstaller和Zope存在问题。

以下是一些参考链接:

找不到模块Zope的问题

PyInstaller无法找到模块Zope - 这个链接也提到了一个潜在的解决方案。

Pyinstaller无法正确处理名称空间包,例如zope.interface

希望这些可以帮助您识别PyInstaller中这个错误的解决方法。

回答Glyph的问题 - 您可以通过编辑运行PyInstaller命令生成的spec文件来定义PyInstaller的其他依赖项。


非常感谢!我已经使用pyinstaller生成了规范文件,并通过查阅文档添加了依赖项,但问题仍然存在,我想我会尝试另一个工具来解决它。仍然感谢您的帮助。 - zorro
@Prahalad - 感谢您的研究 - 尽管这让我想要请您再做一些来完善这个答案 :-). 您能找到任何解决方法吗? - Glyph
2
解决方法在第二个链接中。将 __init__.py 添加到 C:\Python27\Lib\site-packages\zope 文件夹中的 zope 文件夹中。 - frmdstryr

0
我已经在pyinstaller命令中添加了--hidden-import=twisted,一切都运行良好。
pyinstaller --hidden-import=twisted

0

我认为python-zope-interface包对您可能会有所帮助:

yum install python-zope-interface

如果它显示:
Package python-zope-interface-4.0.5-1.fc19.x86_64 already installed
and latest version

运行:

yum erase python-zope-interface
yum install python-zope-interface

我尝试了,它起作用了!


0

zope.interface 是 Twisted 的一个依赖项。在 pyinstaller 中是否有一个配置文件需要声明这个依赖关系呢?


我已经添加了依赖项,但问题仍然存在。我会尝试另一种解决方案,谢谢。 - zorro

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接