代码分析在源文件夹的子目录中不起作用
我正在使用一个 Python 项目,其源文件夹中包含多个子目录。 代码分析似乎仅适用于直接位于 src 文件夹中的脚本。不会分析子文件夹中的所有脚本。
我已将顶级源文件夹添加到 PYTHONPATH。是否还需要添加所有子目录?我正在使用 Eclipse Indigo 和 PyDev 2.4.0。
感谢您的帮助!
I'm working with a Python-Project with several subdirectories within the source folder.
The code analysis seems to work only on scripts directly in the src folder. All scripts in subfolders are not analyzed.
I have added the top-level source folder to the PYTHONPATH. Is it necessary to add all subdirectories as well? I'm using Eclipse Indigo with PyDev 2.4.0.
Thanks for your help!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
可能您的文件位于 PYTHONPATH 下,但不在 python 包下(即:python 包是一个其中包含 __init__.py 文件的文件夹 - 请注意,直到您的模块都需要的所有文件夹拥有该 __init__.py 文件)或者您的文件夹不是有效的 python 名称(在这种情况下,它也不会被视为包 - 即:带有“.”、“-”等的文件夹在名字中)。
如果不是这种情况,请发布 PyDev 包资源管理器的快照。
(作为一般规则,源文件夹的子目录不应设置为源文件夹......尽管您可以支持一些特殊的用例)
Probably your file is beneath the PYTHONPATH but not under a python package (i.e.: a python package is a folder that has an
__init__.py
file in it -- note that all the folders up to your module need to have that__init__.py
file) or your folder is not a valid python name (in which case it's also not treated as a package -- i.e.: folders with '.', '-', etc in the name).If that's not the case, please post a snapshot of the PyDev package explorer.
(as a general rule, subdirectories of a source folder shouldn't be set as source folders... although you can do to support some exceptional use-cases)
您的文件不需要位于
PYTHONPATH
中即可进行代码分析,至少对于我的 PyDev 2.6.0 来说是这样。我只将我的项目(不是包)根目录添加到项目属性中的
PYTHONPATH
中,并分析子目录中的文件。请务必检查目录名称和 python 文件名。它们必须是有效的 python 标识符才能导入进行分析。它不能包含一些看起来无辜的字符,例如点和破折号。
Your files need not to be in
PYTHONPATH
to be code-analyzed,at least this is true for my PyDev 2.6.0.I only add my project(not packages) root dir to
PYTHONPATH
in project properties, and the files in subdirectories are analyzed.Be be sure to check the dir names and python file names. They must be valid python identifier for it to be imported to be analyzed. It cannot contain some innocent-looking characters, like dot and dash.