导入 wxPython 时出错
我刚刚安装了 wxPython,没有任何问题。我在 Snow Leopard Mac 上使用 Python 2.6 并下载了相应的 wxPython 版本。
我首先输入一个非常基本的 wxPython 应用程序,但出现以下错误:
ImportError: No module named wx
代码如下:
import wx
class Application(wx.Frame):
def __init__(self, parent, id):
wx.Frame.__init__(self, parent, id, 'Hello World', size = (300, 200))
if __name__=='__main__':
app = wx.PySimpelApp()
frame = Application(parent = None, id = 1)
frame.Show()
app.MainLoop()
我使用的 Python 版本是否错误,是否是 32/64 位情况错误?如果是这样,我该如何解决?
编辑:强制 python 以 32 位运行,问题仍然存在。
I've just installed wxPython with no problems. I'm on a Snow Leopard Mac using Python 2.6 and downloaded the corresponding wxPython version.
I've started by typing a very basic wxPython app, but I'm getting the following error:
ImportError: No module named wx
The code is the following:
import wx
class Application(wx.Frame):
def __init__(self, parent, id):
wx.Frame.__init__(self, parent, id, 'Hello World', size = (300, 200))
if __name__=='__main__':
app = wx.PySimpelApp()
frame = Application(parent = None, id = 1)
frame.Show()
app.MainLoop()
Am I using a wrong version of Python, is it a 32/64-bit situation bug? If so, how do I solve it?
EDIT: Forced python to run at 32-bit, the issue sustains.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您不能在 64 位模式下使用 wxPython。首先,强制Python使用32位二进制文件:
然后你可以使用内置的Python和内置的wxPython。
You can't use wxPython in 64-bit mode. First, force Python to use the 32-bit binary:
Then you can use the builtin Python and the builtin wxPython.
好吧,问题是我正在运行 python 2.5。
对于所有在安装 wxPython 或任何其他 python 模块时遇到困难的 MacOSX 用户:请确保您的 Python 版本与模块请求的版本相同。 MacOS 中包含的 python 版本往往比上一个稳定版本更旧。
感谢所有帮助过我的人。
Ok, the problem was I was running python 2.5.
To all MacOSX users who get stuck trying to install wxPython or any other python module: make sure your Python version is the same as the requested by the module. The python version included in MacOS tends to be older than the last stable one.
Thank you to all who helped me out.
我很确定你不应该使用 wxPython 的标准 MacPython 安装,但我没有 Mac,所以我不确定......仅供参考:wxPython 的 cocoa 版本确实支持 64 位模式, 尽管。
I'm pretty sure you're not supposed to use the standard MacPython install with wxPython, but I don't have a Mac, so I'm not sure...FYI: The cocoa build of wxPython DOES support 64-bit mode, though.