使用 PyDev 设置 Pylint
我已经通过 easy_install 安装了 pylint。我可以成功运行 pylint
。但 pydev 拒绝使用它。
- 我检查了“使用 pylint”
- 我配置了正确的路径
- 我在 eclipse 中更新了我的 python 解释器以在 pythonpath 中包含 pylit
- 我使用 Eclipse Galileo
- 我已经自动构建检查
- 我尝试清理整个项目并且没有错误
我做错了什么?
I have installed pylint via easy_install. I can run pylint <filename>
with success. But pydev refuses to use it.
- I checked "use pylint"
- I configured correct path
- I updated my python interpreter in eclipse to have pylit in pythonpath
- I use Eclipse Galileo
- I have build automatically checked
- I tried cleaning whole project and no errors
What am I doing wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我猜您可能需要将包含代码的文件夹标记为源文件夹。您可以在项目属性下执行此操作。
I'm guessing you may need to mark the folder that contains your code as a source folder. You can do this under project properties.
我注意到 Pydev 不会在文件名带有破折号(连字符)的文件上运行 Pylint;根据 Pydev 开发人员的说法,“-”不是有效的 Python 模块名称字符,而且看起来他们并不打算修复它:
http://sourceforge.net/tracker/index.php?func=detail&aid=1915426&group_id=85796&atid =577329
http: //sourceforge.net/tracker/index.php?func=detail&aid=2888890&group_id=85796&atid=577332
好像没有人用 Python 编写脚本... 咕咕咕...
I've noticed that Pydev won't run Pylint on files with dashes (hyphens) the the filename; according to the Pydev devs, '-' is not a valid Python module name character, and it doesn't look like they intend to fix it:
http://sourceforge.net/tracker/index.php?func=detail&aid=1915426&group_id=85796&atid=577329
http://sourceforge.net/tracker/index.php?func=detail&aid=2888890&group_id=85796&atid=577332
As if nobody writes scripts in Python... Grumble grumble...
为了提供替代解决方案,
pylint
可以用作 Eclipse 中的外部工具
。这需要事先安装 Python 安装的pylint
包。请记住首先在 pylint 可以找到它的地方有一个
pylintrc
文件,否则会打印“No config file found
”错误。通常,我会触摸 pylintrc
项目目录内的内容,并将文件保留在版本控制中。有关参考,请参阅 pylint 命令行选项。在 Eclipse 中,选择
运行
、外部工具
、外部工具配置...
。单击工具栏按钮创建新启动配置
。按如下方式或根据需要进行配置:pylint
${system_path:pylint}
${project_loc}
--reports=n "${resource_loc}"
请记住在运行上述外部工具之前,在打开的文件内部单击以将焦点切换到该文件。否则,可能会发生错误。
默认情况下,外部工具的输出将打印到控制台。
相关:将 pep8 设置为 Eclipse 中的外部工具
To provide an alternative solution,
pylint
can be used as anExternal Tool
in Eclipse. This requires having previously installed thepylint
package for a Python installation.Remember to first have a
pylintrc
file somewhere where pylint can find it, failing which a "No config file found
" error is printed. Typically I wouldtouch pylintrc
inside the project directory, and keep the file in version control. For reference, see pylint command-line options.In Eclipse, select
Run
,External Tools
,External Tools Configurations...
. Click the toolbar button to create aNew launch configuration
. Configure as below or as desired:pylint
${system_path:pylint}
${project_loc}
--reports=n "${resource_loc}"
Remember to click inside an open file to switch focus to it before running the above external tool for it. Failing this, an error can occur.
The output of the external tool will by default be printed to the console.
Related: Setting up pep8 as an External Tool in Eclipse