简体   繁体   English

虽然使用了Eclipse / PyDev中未使用的导入警告

[英]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" 但是,Eclipse告诉我这个:“未使用的导入:plt发现于: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? 我是Eclipse和PyDev的新手,但应该有一些方法让Eclipse将pyplot识别为plt?

I feel embarrassed. 我感到很尴尬。 The comments from Ignacio and Bakurio already pointed at the right direction. Ignacio和Bakurio的评论已经指出了正确的方向。 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. 这些导入相互干扰,因为pylab也在导入pyplot。 Remove the latter import results in no warning messages anymore in Eclipse. 在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). 我安装了matplotlib 1.3.1(Win 32位; 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. 在我的lib / site-packages /文件夹中,实际上有两个不同的matplotlib文件夹,一个包含实际代码和二进制文件,另一个名为matplotlib-1.3.1-py2.7.egg-info。 I simply deleted the one ending in ...egg-info and it worked. 我只是删除了以... egg-info结尾的那个,并且它有效。 For an explanation, see this thread: http://matplotlib.1069221.n5.nabble.com/ANN-matplotlib-1-3-0rc1-td41151.html . 有关解释,请参阅此主题: http//matplotlib.1069221.n5.nabble.com/ANN-matplotlib-1-3-0rc1-td41151.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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