简体   繁体   English

Eclipse / PyDev错误地将软件包标识为丢失

[英]Eclipse / PyDev falsely identifies package as missing

I am experiencing a very strange issue using Eclipse and PyDev (latest versions as of this post). 我在使用Eclipse和PyDev(本文的最新版本)时遇到了一个非常奇怪的问题。 This is with Python 3.3.2. 这是Python 3.3.2。 I installed the egg for PySNMP which was successful, however in PyDev, my program errors out with this import statement: 我为PySNMP安装了成功的鸡蛋,但是在PyDev中,此导入语句导致程序错误:

from pysnmp.entity.rfc3413.oneliner import cmdgen

This is the Traceback: 这是回溯:

Traceback (most recent call last):
  File "<frozen importlib._bootstrap>", line 1521, in _find_and_load_unlocked
AttributeError: 'module' object has no attribute '__path__'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/alester/workspace/PySNMP Test/pysnmp.py", line 6, in <module>
    from pysnmp.entity.rfc3413.oneliner import cmdgen
  File "/home/alester/workspace/PySNMP Test/pysnmp.py", line 6, in <module>
    from pysnmp.entity.rfc3413.oneliner import cmdgen
ImportError: No module named 'pysnmp.entity'; pysnmp is not a package

On the last line, you can see it says that pysnmp is not a package. 在最后一行,您可以看到它说pysnmp不是软件包。 This is false, and the python interpreter in PyDev is properly configured to reference all the libraries. 这是错误的,并且PyDev中的python解释器已正确配置为引用所有库。

If I go to a terminal and run "python3.3", I can enter that exact same import statement without error. 如果我在终端上运行“ python3.3”,则可以输入完全相同的import语句,而不会出现错误。

Does anybody know how I might fix this? 有人知道我该如何解决吗? :( :(

The problem seems to be that you're naming your module (pysnmp) with the same name of the package you want to use (pysnmp). 问题似乎是您使用与要使用的包(pysnmp)相同的名称来命名模块(pysnmp)。

So, renaming your module should fix the error... 因此,重命名模块应该可以修复错误...

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

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