Configuring Third-Party Tools
In PyCharm, you can specify third-party standalone applications and run them as External Tools. You can pass contextual information to these tools (like the currently selected file or your project source path), view the output within the IDE, configure the tool's launch as a step of your run/debug configuration, and more.
Tools defined in the External Tools dialog appear as commands in the menu and various context menus. Like most other actions, external tools can be assigned keyboard shortcuts for quick access.
Ways to call an external tool:
From the list of available tools in Tools | External Tools on the main menu
Via a keyboard shortcut assigned to the tool in
As the Before launch step of a run/debug configuration
See the next chapter for an example of how to configure and use an external tool.
Example: Adding pylint as an external tool
pylint is a code analyzer tool that checks your code and detects any style, logic, and usage problems. It might be a great addition to the code validation features available with PyCharm.
To install pylint
-
In the Settings/Preferences dialog (Ctrl+Alt+S) navigate to .
-
Click the button to install a new package.
-
In the Available packages window, search for "pylint", then choose it in the list of packages, and click Install Package.
Wait until the package is installed and close the window.
Now that you have installed pylint on your system, you can configure its integration with Pycharm.
To configure pylint
In the Settings/Preferences dialog (Ctrl+Alt+S) navigate to .
Click the button to add a new external tool.
Add configuration options as shown below:
Group – the name of the external tool group to show in the menu
Name – the external tool name
Description – an optional description
Program – the path to the pylint executable (
$PyInterpreterDirectory$
is a directory where the Python interpreter of the current project is placed).
Example:$PyInterpreterDirectory$\pylint
$PyInterpreterDirectory$/pylint
(Linux, macOS)Argument – specifies what files and folders should be checked (
car.py
andtest
in this example) and sets the output format for pylint errors.
Example:--msg-template="$FileDir$\{path}:{line}:{column}:{C}:({symbol}){msg}" car.py test
--msg-template="$FileDir$/{path}:{line}:{column}:{C}:({symbol}){msg}" car.py test
Working directory – project root directory
It is recommended to enable all options from the Advanced Options section and set up the Output filters to insert links to the files with errors into the pylint output, so you can quickly jump to an error or warning in your code.
-
Click OK to save the changes. Complete adding an external tool by clicking Apply and OK in the External Tools window.
Now you can access this external tool from the
.You can run pylint using this menu. However, you might also want to add it to the Run/Debug Configuration of your application.
To execute pylint right before your application run
From the main menu, choose Edit Configurations dialog, click in the Before launch section.
, then in theSelect Run External tool from the Add new configuration list and specify pylint. It will be added to the list of scripts to be executed before the application launch.
Click OK to save the changes
Run the Run/Debug configuration (Shift+F10).
You should expect to see the pylint tab in the Tools window with the following sample output:
You can inspect the reported errors, click the corresponding links to navigate to the problematic code, and made the required changes.