I'm using PyDev in Eclipse and recently installed the wxPython libraries - it imports fine using IDLE, etc, and when I run a Python program using wxPython it runs fine - but one little thing really bugs me. For some reason, despite making sure that wx and wxPython are in the 'Forced Builtins' section of the PyDev preferences, PyDev refuses to recognise any of the things I do with wx:
Undefined variable from import: Frame
And the like are the messages - all I see is little X's and squiggly red underlines, so you can imagine how irritating this is.
Has anyone encountered this problem with PyDev & wxPython before, and/or know how to fix it? Last time I had the problem, it was due to the Forced Builtins not being properly set up but I can't see how that is the problem this time.
You will find that this problem extends even the wxPython code imports. It will affect importing even your own modules. Seemingly at random from my POV. Despite this, the code will run fine, it's just the editor that lies. I've given up on figuring out this problem months ago. Despite this issue, I still find the benefit of pydev in Eclipse far outweighs the problem. I don't want this to sound like a flame. It's not. In fact, if you're a new pydev user, you'll soon come to find that Fabio does a great job supporting us users.
Yeah, I have actually realised this - all the searches I did on Google for solutions to a similar problem came up with his name. I guess I'll just have to deal with it. Oddly though it doesn't seem to affect MySQLdb, which isn't included with Python 2.6 is it?
I'm kind of hoping that one day I will fire up PyDev and the problem will just be gone for some reason.
Anyway thanks for the reply!
Please enter a bug report for that, with details on the versions you're using (python, wxpython, platform, pydev, eclipse) and a sample code where it's failing.
just for the record and for the search engines:
I was fighting with the same problem and also initially found no solution (but now it works, see below).
While searching for solutions I have found a lot of threads here and elsewhere dealing with this problem, many of them suggest:
* removing and re-adding the python interpreter
* adding wx and wxPython to the forced builtins
* check that the pythonpath is correct
Here is now what happened to me:
I recently decided working on an old wxPython application again after doing nothing python related for nearly 2 years and therefoe I installed a fresh new copy of eclipse Helios and the latest release of PyDev
Although it is now already January 2011 I still have Ubuntu Hardy which has Python 2.5 and wxpython 2.8
The same problem as described above and in the many other threads occurred. Every import in my project was recognized by PyDev except anything that had to do with wx. I had hundreds of lines marked as error.
I then tried the following:
* removed and re-added the python interpreter (no success)
* added all subdirectories of the wxpython directory individually to the python path (no success)
* tried the same in the project settings / external libraries (no success)
* made sure that wx is in the "forced builtins" list (it is there already by default, so I did nothing -> no success)
* removed the python nature from the project and re-added it (no success)
* closed / opened / refreshed the project, closed and re-started eclipse (no success)
I was at the point of giving up now.
* Then I _REMOVED_ wx from the forced builtin list and IMMEDIATELY it started all working like a charm!
So it seems there is no reason why wx should be on the forced builtins list, obviously it can all work without it being there and putting it there might do more harm than good! Maybe it should not be there by default. I don't know exactly what this "forced builtin" really does internally but it seems at least on my machine (which has a pretty standard configuration) it seems to do the wrong thing.
I think you can remove your python interpreter first (preference -> Interpreter - Python )， then add it back to you IDE again,it will refresh your system libs . good luck
just like what prof7bit said in 5 ,I also tryed everything he list. A little difference with him is that even I removed wx from forced builtin list, workless.
Now I fixed this solution ,but I still not know how I have done it.
First time I fixed this with removing 'import wx' then importing it , just like a charm!
Second time,this way dose not work,I have to find a new way. I closed eclipse,then open it, success.
I do not know why it works,but it does.
How can I do the third time? Restart my computer?Hah
I used 'from wx import Frame' instead of 'import wx' ,so I have to use Frame instead of wx.Frame. Although this way is not suggested, it works well.
Sign up for the SourceForge newsletter:
You seem to have CSS turned off.
Please don't fill out this field.