Jaliborc
Jaliborc

Reputation: 353

Error Importing wxPython

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.

Upvotes: 2

Views: 2734

Answers (3)

Jaliborc
Jaliborc

Reputation: 353

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.

Upvotes: 1

Mike Driscoll
Mike Driscoll

Reputation: 33071

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.

Upvotes: 0

Rafe Kettler
Rafe Kettler

Reputation: 76945

You can't use wxPython in 64-bit mode. First, force Python to use the 32-bit binary:

defaults write com.apple.versioner.python Prefer-32-Bit -bool yes

Then you can use the builtin Python and the builtin wxPython.

Upvotes: 1

Related Questions