0

My python version is 2.7 and wxPython ver 3.0 for python 32 bit 2.7 version. I was currently working on a GUI app with wxPython. I tested my code it was working fine, I paused my work saved my files. I started to install some software on my machine. Then when I again started to continue my work with wxPython suddenly I started to receive an error. The complete error is given below. I don't understand the reason. I didn't edit my code too. However I am able to execute my other python programmes.

Error:

File "C:\Python27\lib\site-packages\wx-3.0-msw\wx\lib\scrolledpanel.py", line 21, in <module>
    class ScrolledPanel( wx.PyScrolledWindow ):
AttributeError: 'module' object has no attribute 'PyScrolledWindow'

I reinstalled wxPython but nothing changed. I tried to investigate using google. But all in vain. Can some provide me some advice on this?

The python code has following import statements:

import wx
import wx.lib.scrolledpanel

and I using the imports like this:

panel = wx.lib.scrolledpanel.ScrolledPanel(self, -1, size=(1000,500), pos=(0,50), style=wx.SIMPLE_BORDER)

Thanks for your time.

11
  • try adding the line wx = wx after import wx. Let me know what you get after doing that... Commented Feb 4, 2014 at 11:43
  • @gravetii I'll try. currently I am reinstalling python and wxPython. I'll update as soon as I try your solution. Commented Feb 4, 2014 at 11:45
  • If you are reinstalling anyway, try a bit older version than 3.0. Commented Feb 4, 2014 at 11:48
  • @gravetii nothing changed by using your idea. Same error. Commented Feb 4, 2014 at 11:53
  • @Fenikso I am using python 2.7.6 and wxPython 32-bit Python 2.7. Commented Feb 4, 2014 at 11:54

3 Answers 3

1

As per our chat: You have your project files located on Desktop. There are probably many more .py files on your desktop. Some of them shadow your imported library name, maybe something like wx.py. So instead of importing wx library, you import something else, what does not have needed contents.

Try running your code in a more controlled environment, e.g. create a directory for your project, double check file names in that directory and your Python path for shadowing names. It should work.

Sign up to request clarification or add additional context in comments.

1 Comment

@fenisko Thanks, This is quite a strange problem it can even happen if there is no file named wx.py or something. (This was my case). The lesson learnt by me is to programme in a controlled & clean environment.
1

The following works for me:

import wxversion
wxversion.select('3.0')
import wx

Comments

0

Following has worked for me:

import wxversion
wxversion.select('3.0')
import wx

PS When you use python env, you may see a tip "select xxx".

1 Comment

Answer can be a little more detailed and code should be highlighted .you can give examples to support your answer.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.