Eclipse PyDev now shows all references to Tkinter

2020-04-09 23:47发布

I've been using Eclipse with PyDev (on Windows, mind you) for my Python Tkinter project for about a month now, and up until recently I've had no complaints. I start the source for one module (my GUI) like so:

from Tkinter import *

Now, ever since I updated Eclipse to 3.6.1, it shows an error for every call to the Tkinter module(Frame(), Label(), Tk(), etc.). I thought that something might have gone wrong during the update, so I uninstalled Eclipse, re-downloaded it (Eclipse 3.6.1 Classic), and reinstalled it. Then, seeing that that gave me a bunch of errors with installing PyDev, I removed that, got Eclipse 3.6.0 Classic, installed it, and got the same problem I was trying to fix earlier.

I don't understand what's wrong here. It doesn't make any sense to me why all of a sudden Eclipse would stop recognizing that I had imported Tkinter.

Can anyone offer any suggestions/input? I really want to stick with Eclipse, I'm very happy with it, but I can't deal with it giving me about 200 bogus errors.

3条回答
家丑人穷心不美
2楼-- · 2020-04-10 00:27

You really shouldn't use wild imports. Consider from Tkinter import Frame, Label or import Tkinter as tk instead.

Now to your problem: I have Eclipse Helios, too (3.6.0.v20100602). The problem you describe clearly has to do with PyDev, not with the Eclipse base project. I just tried the same import and didn't get error messages. My PyDev version also retrieves the docstring of Frame correctly, for example.

I think it boils to just installing a newer version of PyDev (this is the solution for many bugs ^^) - add "http://pydev.org/nightly" as an update site and then upgrade to the latest version. I have version 1.6.3.20100922, by the way. If that doesn't help, you should consider reporting it as a bug.

查看更多
霸刀☆藐视天下
3楼-- · 2020-04-10 00:32

Which Python version do You use? If > 3.1 try (note lowercase writing):

from tkinter import *
查看更多
对你真心纯属浪费
4楼-- · 2020-04-10 00:36

I find the answer to problems like this is usually that you have to update your pythonpath from eclipse. See my answer to a similar question. I think re-installing pydev and/or eclipse usually solves this problem because in doing so, the pythonpath is re-configured.

查看更多
登录 后发表回答