PyDev 在项目源文件夹中找不到模块
好吧,这不是我第一次遇到这个问题,但这一次它确实把我逼到了边缘。问题是这样的。我正在 Linux 和 Windows 上开发一些东西,通过 dropbox 共享工作区并在解释器之间切换。有时,项目会停止执行。我得到的错误是:
Traceback (most recent call last):
File "C:\Users\SomeUser\Dropbox\Workspace\NetworkNamingGame\src\naminggame\analyzer.py", line 13, in <module>
from naminggame import util
ImportError: No module named naminggame
有趣的是,NetworkNamingGame\src 是项目的源文件夹。 Naminggame 是那里唯一的包。包资源管理器成功将其识别为包并显示相关图标。
我意识到这可能是由于源文件夹更改路径引起的(尽管我认为它们是相对路径),因此我多次尝试删除项目源文件夹并将其重新添加到源文件夹列表中,“强制恢复内部信息”,清理该项目,删除 PyDev 配置并重试上述所有操作,但没有运气。当我检查 PyDev 执行的 python 解释器命令时,我可以看到源文件夹不在 PYTHONPATH 中。我找到的唯一解决方案是将整个内容导入到新项目中。如果你问我的话,这不是一个很好的解决方案。
如果这是一个外部文件夹,我只会有点生气,但它就在那里!这是我的配置应该查看的第一个也是唯一一个文件夹。有什么想法为什么会发生这种情况以及如何解决它而不从头开始一切吗?
版本位:
Eclipse SDK
版本:3.6.1
构建 ID:M20100909-0800
PyDev
版本:1.6.5.2011020317
以及根据请求命名游戏文件夹的内容:
$:~/Dropbox/Workspace/NetworkNamingGame/src/naminggame$ ls
abc.png analyzer.py concatenate_logs.py game.py logs profiler_output server.py triangle.gif
Analyzer.log circle.gif concatenate_logs.py~ __init__.py net.py rectangle.gif simulation.py util.py
analyzer_old.py client.py csv_generator.py log pentagon.gif Server.log success_data_50-150agents.anova.csv
Okay, so this is not the first time I've had this problem, but it really has driven me to the edge this time. The problem is this. I am developing something on Linux and Windows, sharing the workspace via dropbox and switching between interpreters. Occasionally, the project stops being executable. The error I get is:
Traceback (most recent call last):
File "C:\Users\SomeUser\Dropbox\Workspace\NetworkNamingGame\src\naminggame\analyzer.py", line 13, in <module>
from naminggame import util
ImportError: No module named naminggame
Interestingly, NetworkNamingGame\src is the source folder of the project. And naminggame is the only package there. Package explorer successfully recognizes it as a package and shows the relevant icon.
I realize this could be caused by source folder changing paths (although I thought they were relative paths), so I have repeatedly tried to remove and readd the project source folder to the list of source folders, "forced restore internal info"s, cleaning the project, removing PyDev configurations and retrying all of the above, but no luck. When I check the python interpreter command that is executed by PyDev, I can see that the source folder is not in the PYTHONPATH. The only solution I've found is to import the whole thing into a new project. Not a very good solution if you ask me.
I would be only moderately pissed off if this was an external folder, but it is right there! It is the first and only folder it should be looking at with my configuration. Any ideas why this happens and how to fix it without starting everything from scratch?
Versions bit:
Eclipse SDK
Version: 3.6.1
Build id: M20100909-0800
PyDev
Version: 1.6.5.2011020317
And the contents of the naminggame folder upon request:
$:~/Dropbox/Workspace/NetworkNamingGame/src/naminggame$ ls
abc.png analyzer.py concatenate_logs.py game.py logs profiler_output server.py triangle.gif
Analyzer.log circle.gif concatenate_logs.py~ __init__.py net.py rectangle.gif simulation.py util.py
analyzer_old.py client.py csv_generator.py log pentagon.gif Server.log success_data_50-150agents.anova.csv
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
请升级到最新的 PyDev(目前为 2.2.1),因为它应该会为您“修复”该问题。如果您仍然遇到问题,请发布此项目的 PyDev 包资源管理器的屏幕截图。
Please upgrade to the latest PyDev (2.2.1 at this time), as it should 'fix' that for you. If you still have the issue, please post a screenshot of your PyDev package explorer for this project.