【发布时间】:2014-11-11 02:33:00
【问题描述】:
我正在尝试使用“imp”库来导出 PyQt4 的所有符号。使用内置的“import PyQt4.QtCore”是可以的,但是python的代码失败了。 我的测试基于 Mac。 在Windows上,好像如果你在QtCore目录下放一个“init.py”(空文件也可以), “导入 QtCore”会成功。 但在 Mac 上,由于某种未知原因,它失败了。 在 Cli 中:
bash-3.2# python
Python 2.7.5 (default, Mar 9 2014, 22:15:05)
[GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.0.68)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import PyQt4.QtCore as f
>>> print f.__file__
/Library/Python/2.7/site-packages/PyQt4/QtCore.so
但是,这种用法失败了。
bash-3.2# cd /Library/Python/2.7/site-packages/PyQt4/
bash-3.2# python
Python 2.7.5 (default, Mar 9 2014, 22:15:05)
[GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.0.68)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import QtCore
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
SystemError: dynamic module not initialized properly
谁能解释一下?
【问题讨论】: