External tools
Configure third-party command-line applications as external tools to run them from PyCharm. For example, your workflow may require running a specific script, code generator, analyzer, preprocessor or postprocessor, some database utility, and so on. By configuring it as an external tool, PyCharm provides a dedicated action for it, which you can run from the main menu, from certain context menus, assign a shortcut to it, or run it when launching a specific run configuration.
You can use built-in IDE macros to pass context-dependent command-line arguments to the tool, such as the current file or your project source path. If necessary, PyCharm will print the tool's output to the console.
PyCharm supports the following types of external tools:
Local tools run locally on your computer.
Remote tools are executed on a remote server over SSH.
note
You can add and run remote tools only in PyCharm Professional.
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.
Press CtrlAlt0S to open settings and then select Project | Python Interpreter.
Click 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.
Press CtrlAlt0S to open settings and then select Tools | External Tools.
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 Tools | External Tools 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:WindowsLinux, macOS$PyInterpreterDirectory$\pylint
$PyInterpreterDirectory$/pylint
(Linux, macOS)Argument: Specifies what files and folders should be checked (car.py and test in this example) and sets the output format for pylint errors. Example:
WindowsLinux, macOS--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 Tools | External Tools.
You can run pylint using this menu. However, you might also want to add it to the Run/Debug Configuration of your application.
Go to Run | Edit Configurations, then in the Edit Configurations dialog, click in the Before launch section.
Select 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 ShiftF10.
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.
warning
Make sure the FTP/SFTP/WebDAV Connectivity and HTTP Client plugins are installed and enabled. Press CtrlAlt0S to open settings and then select Plugins.
Remote SSH external tools are configured similarly to local external tools, but also define the remote server on which they are executed and require credentials for connecting to it via SSH.
This example demonstrates how to add date
as a remote SSH external tool that is executed on a remote server over SSH and returns the current date and time on it.
Press CtrlAlt0S to open settings and then select Tools | Remote SSH External Tools.
Click to open the Create Tool dialog.
This dialog provides the same set of settings as when you add a local external tool, but also allows you to select a remote connection. If you don't specify the connection settings, PyCharm will ask you for the host, port, and relevant SSH credentials every time you run the tool on the server. For more information, refer to Remote SSH External Tools.
tip
You can use built-in IDE macros to specify the name of the current file, paths relative to the project root, and other contextual information for the tool.
Click OK to add the tool and then apply the changes.
Do one of the following:
In the main menu, go to Tools | Remote Tools and the name of the added remote external tool.
Create a shortcut to run the tool.
Press CtrlAlt0S to open settings and then select Keymap. Find the action with the name of your configured remote external tool, and assign a shortcut for it.
After you specify the host, port, and credentials, PyCharm will connect to the server via SSH and run the date
command, returning the output to the Run tool window in PyCharm.
You can use a web browser to open any file from your project. By default, it is used to preview the output of an HTML file or run and debug web applications.
To open a file that is intended to be rendered by a web browser (HTML, XML, JSP, and so on), do one of the following:
Open the file in the editor and press AltF2.
Right-click the file in the Project tool window and select Open in Browser.
In the main menu, go to View | Open in Browser.
Use the browser popup in the top right part of the editor window (appears on hover). Click the browser button to open the web server file URL, or ShiftClick it to open the local file URL.
The Open in Browser action is not available for other file types. However, you can still execute it using Find Action CtrlShift0A.
note
By default, PyCharm supports some of the most popular browsers, which are configured automatically, if available.
In the Settings dialog (CtrlAlt0S) , select Tools | Web Browsers and Preview.
If a browser was installed using a standard procedure, the alias in the Path field should point to the right location. If it does not, specify the path to the corresponding executable file.
tip
To add a custom browser, click and specify the browser name, family, and location of the executable file or macOS application.
You can configure custom profiles for Firefox and Chrome family browsers.
In the Settings dialog (CtrlAlt0S) , select Tools | Web Browsers and Preview.
Select the browser in the list and click .
For Firefox, specify the path to the profiles.ini file and choose the profile to use. For more information, refer to Firefox browser profile.
For Chrome, select Use custom user data directory and specify the location of the user data directory.
You can also specify additional command-line options to use when running Chrome from PyCharm. For more information, open
chrome://flags
in the Chrome address bar.
Thanks for your feedback!