使用 PyDev 设置 Pylint

发布于 2024-08-26 13:37:54 字数 308 浏览 6 评论 0原文

我已经通过 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

要走干脆点 2024-09-02 13:37:54

我猜您可能需要将包含代码的文件夹标记为源文件夹。您可以在项目属性下执行此操作。

  • 项目->属性->PyDev-PYTHONPATH
  • 将相关文件夹添加到源列表中。

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.

  • Project->Properties->PyDev-PYTHONPATH
  • add relevant folders to the list of sources.
半衾梦 2024-09-02 13:37:54

我注意到 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...

念三年u 2024-09-02 13:37:54

为了提供替代解决方案,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 an External Tool in Eclipse. This requires having previously installed the pylint 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 would touch 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 a New launch configuration. Configure as below or as desired:

  • Name: pylint
  • Location: ${system_path:pylint}
  • Working Directory: ${project_loc}
  • Arguments: --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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文