wxPython AttributeError: module has no attribute 'Frame'
Solution 1
You have a local wx.py
file in the same directory. Python imports that file instead of the wx
package.
Remove or rename that file.
Solution 2
I guess you might have installed wx using pip. You may try to install wx by running the executable file from its homepage. I tried and it worked.
raspberry.pi
A computer nerd who sucks at math but excels in computers trying to learn python in a busy life.
Updated on June 04, 2022Comments
-
raspberry.pi almost 2 years
I'm trying to learn wxPython and when I'm following the tutorial to learn it. I'm encountering some errors. I have done a bunch of research and can't find anything on this site that relates to my situation and I've also re installed and tried all the different versions of wxpython for python 2.7 there is still no difference. I'm on a Dell Windows 8 computer 64-bit. Here is the code from the tutorial:
import wx class MyFrame(wx.Frame): def __init__(self, parent, title): wx.Frame.__init__(self, parent, title=title, size=(200,100)) self.control = wx.TextCtrl(self, style=wx.TE_MULTILINE) self.Show(True) app = wx.App(False) frame = MyFrame(None, 'Small editor') app.MainLoop()
and the error:
Traceback (most recent call last): File "C:\Python27\test", line 2, in <module> class MyFrame(wx.Frame): AttributeError: 'module' object has no attribute 'Frame'