问题
I am importing a plotting package in my file like this:
import matplotlib.pyplot as plt
and am using this import later on in my code successfully(!)
fig = plt.figure(figsize=(16,10))
However, Eclipse is telling me this: "Unused import: plt Found at: matplotlib.pyplot"
There might be a very simple solution for this, but I could not find it on the internet. I am new to Eclipse and PyDev, but there should be some way so that Eclipse recognized pyplot as plt?
回答1:
I feel embarrassed. The comments from Ignacio and Bakurio already pointed at the right direction. In fact, next to
import matplotlib.pyplot as plt
I am also importing
from pylab import *
These imports interfere with one another, since pylab is also importing pyplot. Remove the latter import results in no warning messages anymore in Eclipse. Next time I'll paste the full source code.
回答2:
I solve this problem going to Project -> Properties -> PyDev - PYTHONPATH and click on "Force restore internat info".
回答3:
I had the same problem. I installed matplotlib 1.3.1 (Win 32 bit; Python 2.7.6). In my lib/site-packages/ folder there were actually two different matplotlib folders, one containing the actual code and binaries, and another one called matplotlib-1.3.1-py2.7.egg-info. I simply deleted the one ending in ...egg-info and it worked. For an explanation, see this thread: http://matplotlib.1069221.n5.nabble.com/ANN-matplotlib-1-3-0rc1-td41151.html.
来源:https://stackoverflow.com/questions/13305468/unused-import-warning-in-eclipse-pydev-although-it-is-used