Eclipse/PyDev中未使用的导入警告(尽管已使用) [英] Unused import warning in Eclipse/PyDev although it is used

查看:67
本文介绍了Eclipse/PyDev中未使用的导入警告(尽管已使用)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在像这样在我的文件中导入绘图包:

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))

但是,Eclipse告诉我这一点:未使用的导入:plt位于:matplotlib.pyplot"

However, Eclipse is telling me this: "Unused import: plt Found at: matplotlib.pyplot"

对此可能有一个非常简单的解决方案,但我无法在Internet上找到它.我是Eclipse和PyDev的新手,但是应该有某种方法可以使Eclipse将pyplot识别为plt?

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?

推荐答案

我感到很尴尬.伊格纳西奥(Ignacio)和巴库里奥(Bakurio)的评论已经指出了正确的方向.实际上,在

I feel embarrassed. The comments from Ignacio and Bakurio already pointed at the right direction. In fact, next to

import matplotlib.pyplot as plt

我也在导入

from pylab import *

这些导入会互相干扰,因为pylab也在导入pyplot.在Eclipse中,删除后者的导入结果将不再显示任何警告消息.下次,我将粘贴完整的源代码.

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.

这篇关于Eclipse/PyDev中未使用的导入警告(尽管已使用)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆