4 Replies - 5915 Views - Last Post: 09 May 2011 - 08:39 AM Rate Topic: -----

#1 thomasbomb  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 29
  • Joined: 10-January 11

wxPython Error 'module' has no attribute 'app'

Posted 16 January 2011 - 11:17 AM

I was following the tutorials on Youtube for Python made by thenewboston (not trying to advertise) and he was using wxPython for GUI. I install it and he used the following code to check if it was installed right:

import wx
app = wx.App()
win = wx.Frame(None)
win.Show()
app.MainLoop()


When I run it I get the error:

Traceback (most recent call last):
File "C:\Python27\test.py", line 2, in <module>
app = wx.App()
AttributeError: 'module' object has no attribute 'App'

Does anyone know how to fix this? The wxPython installed it the directory
C:\Python27\Lib\site-packages if you were wondering.

Is This A Good Question/Topic? 1
  • +

Replies To: wxPython Error 'module' has no attribute 'app'

#2 Motoma  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 452
  • View blog
  • Posts: 796
  • Joined: 08-June 10

Re: wxPython Error 'module' has no attribute 'app'

Posted 16 January 2011 - 12:01 PM

I have really no experience with wx, however, what I can glean is that the module imported successfully, and it doesn't find the App class. While this may seem pretty obvious, it gives you a place to start; in the interactive prompt, try the following:

>>> import wx
>>> dir(wx)



Read through each of the objects and compare them to the listing on the wxPython doc. If app shows up there, it may be a simple matter of missing capitalization, if not, it may be bad install.

Another potential issue is that the importing wx doesn't actually load the App class (but I don't know why it wouldn't). In that case you may need to do "from wx import App" or something along those lines, and call "App()" directly.
Was This Post Helpful? 0
  • +
  • -

#3 Fixion  Icon User is offline

  • New D.I.C Head

Reputation: 3
  • View blog
  • Posts: 7
  • Joined: 18-October 10

Re: wxPython Error 'module' has no attribute 'app'

Posted 16 January 2011 - 12:53 PM

Try this:
app = wx.PySimpleApp()
#....
app.MainLoop()


This post has been edited by Fixion: 16 January 2011 - 12:53 PM

Was This Post Helpful? 0
  • +
  • -

#4 thomasbomb  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 29
  • Joined: 10-January 11

Re: wxPython Error 'module' has no attribute 'app'

Posted 16 January 2011 - 08:24 PM

Neither has worked. I tried uninstalling and reinstalling and it still didn't work. Are there any other GUI types that you would recommend?
Was This Post Helpful? 0
  • +
  • -

#5 crzdot  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 09-May 11

Re: wxPython Error 'module' has no attribute 'app'

Posted 09 May 2011 - 08:39 AM

Today I get the same error.
My reason is I give my python file the name 'wx.py'.
Hope can help you.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1