简体   繁体   中英

Unused import warning in Eclipse/PyDev although it is used

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?

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.

我解决了这个问题,转到Project - > Properties - > PyDev - PYTHONPATH并点击“强制恢复国际信息”。

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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM