如何使用 PyCharm 运行 Pylint [英] How to run Pylint with PyCharm

查看:69
本文介绍了如何使用 PyCharm 运行 Pylint的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在我正在处理的 Python 项目的整个项目目录中将 Pylint 配置为外部工具.我尝试将存储库用作带有 __init__.py 和不带的模块,但无论如何它都不起作用.

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

他们文档中的权威来源已损坏,因此我也无法检查.

解决方案

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

  1. 安装pylint:

     $ pip install pylint

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

     $ which pylint # MacOS/Linux/usr/local/bin/pylint # 这只是一个可能的输出 - 检查你的<!-->$ where pylint # Windows%LocalAppData%\Programs\Python\Python36-32\Scripts\pylint.exe # 可能的位置

  3. 使用菜单文件设置打开PyCharm设置窗口,然后导航到菜单工具外部工具 在侧边栏中.(或搜索外部工具")

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

  5. 从菜单工具运行pylint外部工具pylint:

  6. 在 PyCharm 终端中查看您的输出

有关更多详细信息,请参阅

I want to configure Pylint as an external tool in my entire project directory for a Python project that I'm working on. I've tried to use the repository as a module with __init__.py and without, and it's not working either way.

I'm having difficulty setting up Pylint to run with PyCharm. I know that I should be running it as an external tool, however the settings confuse me.

The authoritative source on their documentation is broken, so I can't check that up either.

解决方案

You can set up Pylint to work with PyCharm by following the following steps:

  1. Install pylint:

     $ pip install pylint
    

  2. Locate your pylint installation folder:

     $ 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. Open the PyCharm settings window with menu FileSettings, then navigate to menu ToolsExternal Tools in the sidebar. (Or search "external tools")

  4. Set up an external tool by clicking on the + sign and filling in the fields accordingly. In Program use the path you got when running which pylint. For the other values, you can use the same from the image.

  5. Run pylint from menu ToolsExternal Toolspylint:

  6. Look at your output in the PyCharm terminal

For more details, refer to Pylinting with PyCharm.

If you want to use Pylint to check your whole project or a particular file or directory, you can right click on your project root, file or directory, then activate External Toolspylint as shown below.

这篇关于如何使用 PyCharm 运行 Pylint的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆