如何使用 PyCharm 运行 Pylint

2024-05-17

我想将 Pylint 配置为我正在处理的 Python 项目的整个项目目录中的外部工具。我尝试将存储库用作模块__init__.py没有的话,这两种方式都不起作用。

我在设置 Pylint 与 PyCharm 一起运行时遇到困难。我知道我应该将它作为外部工具运行,但是这些设置让我感到困惑。

他们文档上的权威来源已损坏,所以我也无法检查。


您可以按照以下步骤设置 Pylint 以与 PyCharm 配合使用:

  1. Install pylint:

     $ pip install pylint
    
  2. 找到您的pylint安装文件夹:

     $ which pylint         # MacOS/Linux
     /usr/local/bin/pylint  # This is just a possible output - check yours
    
    <!-->
    
     $ where pylint         # Windows
     %LocalAppData%\Programs\Python\Python36-32\Scripts\pylint.exe  # Possible location
    
  3. 使用菜单打开 PyCharm 设置窗口FileSettings,然后导航至菜单Tools外部工具在侧边栏中。 (或搜索“外部工具")

  4. 通过单击设置外部工具+相应地签署并填写字段。在Program使用运行时获得的路径which pylint。对于其他值,您可以使用图像中的相同值。

  5. Run pylint从菜单Tools外部工具pylint:

  6. 查看 PyCharm 终端中的输出

欲了解更多详情,请参阅使用 PyCharm 进行 Pylinting https://kirankoduru.github.io/python/pylint-with-pycharm.html.

如果您想使用 Pylint 检查整个项目或特定文件或目录,您可以右键单击您的项目根目录、文件或目录,然后激活外部工具pylint如下所示。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

如何使用 PyCharm 运行 Pylint 的相关文章

随机推荐