Python:来自imp

2024-05-20 13:36:53 发布

您现在位置:Python中文网/ 问答频道 /正文

我在Ubuntu 10.10上运行Python 2.6.6。

我知道我们可以导入一个模块并将该模块绑定到另一个名称,例如

import spam as eggs

还有

from eggs import spam as foo

我的问题是,当运行PySide examples时,以下导入代码不会运行:

import PySide as PyQt4
from PyQt4 import QtCore, QtGui

它会生成导入错误:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named PyQt4

显然,根据Python解释器,上面的代码是不正确的,我的问题是为什么它是不正确的,或者说为什么这不起作用?


Tags: 模块代码fromimport名称fooubuntuas