PyCharm 2019.2 Help

External tools

You can define standalone third-party applications as external tools and run them from PyCharm. For example, you might want to run a code generator or analyzer, preprocessor or postprocessor, a database utility, and so on.

You can pass contextual information from your project to the external tool as command-line arguments (for example, the currently selected or open file, the project source path, and so on), view the output produced by the tool, configure to launch the tool before a run/debug configuration, and more.

There are different types of external tools that you can use with PyCharm:

  • Local external tools are applications that run locally on your machine.

  • Remote SSH external tools are executed on a remote server over SSH.

Add a local 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.

  1. In the Settings/Preferences dialog (Ctrl+Alt+S), select Project | Project Interpreter.

  2. Click add a package to install a new package.

  3. In the Available packages window, search for "pylint", then choose it in the list of packages, and click Install Package.

    pylint installation

    Wait until the package is installed and close the window.

  4. Now that you have installed pylint on your system, you can configure its integration with PyCharm.

    In the Settings/Preferences dialog (Ctrl+Alt+S) navigate to Tools | External Tools.

  5. Click the add an external tool button to add a new external tool.

  6. Add configuration options as shown below:

    Configure pylint as an external tool
    • 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:

      $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:

      --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.

  7. 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.

pylint is shown in the External Tools menu

You can run pylint using this menu. However, you might also want to add it to the Run/Debug Configuration of your application.

Run the external tool

  1. From the main menu, choose Run | Edit Configuration, then in the Edit Configurations dialog, click Run pylint before start in the Before launch section.

  2. 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.

    Adding pylint to the Run/Debug configuration
  3. Click OK to save the changes

  4. Run the Run/Debug configuration Shift+F10.

    Run the script

    You should expect to see the pylint tab in the Tools window with the following sample output:

    code validation with pylint

You can inspect the reported errors, click the corresponding links to navigate to the problematic code, and made the required changes.

Add a remote SSH external tool

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 you can add date as a remote SSH external tool that is executed on a remote server and returns the current date and time on it.

  1. In the Settings/Preferences dialog (Ctrl+Alt+S), select Tools | Remote SSH External Tools.

  2. Click the Add button and specify the following settings:

    The Create Tool dialog

    This dialog provides the same set of settings as when you add a local external tool, but selecting the remote server is also suggested. This can be one of your configured deployment servers or a Vagrant box. By default, PyCharm will ask you for the host, port, and relevant SSH credentials every time you run the tool on the deployment server.

  3. Click OK to add the tool and then apply the changes.

To run the added date tool on a remote server, do one of the following:

  • From the main menu, select Tools | Remote tools | Date and time.

  • In the Settings/Preferences dialog (Ctrl+Alt+S), select Keymap, find the Date and time action, and assign a shortcut for it. Use the shortcut to run the tool.

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.

Web browsers

You can use a web browser to open any file from your project but generally it is used to preview the output of an HTML file or run and debug web applications.

Open a file in a web browser

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:

  • Press Alt+F2.

  • Right-click a file and select Open in Browser.

  • From the main menu, select View | Open in Browser.

  • Use the browser popup in the top right part of the editor window. Click the browser button to open the web server file URL, or Shift+Click it to open the local file URL.

    The Browser popup in the editor

The Open in Browser action is not available for other file types. However, you can still execute it using Find Action Ctrl+Shift+A.

By default, PyCharm supports some of the most popular browsers, which are configured automatically, if available:

  • Chrome Chrome browser icon

  • Firefox Firefox browser icon

  • Safari Safari browser icon

  • Opera Opera browser icon

  • Internet Explorer Internet Explorer browser icon

  • Edge Edge browser icon

View and configure the list of browsers

  • In the Settings/Preferences dialog (Ctrl+Alt+S), select Tools | Web Browsers.

The Web Browsers page in Preferences

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.

The order of browsers in the list corresponds to their order in the popup, context menu, and the View menu. If you disable a browser, it will not appear in the popup, context menu, and the View menu.

Add a custom browser

  1. In the Settings/Preferences dialog (Ctrl+Alt+S), select Tools | Web Browsers.

  2. Click the Add button and specify the browser name, family, and location of the executable file or macOS application.

Select a default browser

The Open in Browser item in the View menu and in the context menu of a file lists all available browsers and the default browser, which is also used to render external resources.

  1. In the Settings/Preferences dialog (Ctrl+Alt+S), select Tools | Web Browsers.

  2. From the Default Browser list, choose one of the following:

    • System default: use the default browser for your operating system.

    • First listed: use the first browser in the list.

    • Custom path: use a browser that is not in the list. Specify the location of the executable file.

Use custom profile and settings

You can configure custom profiles for Firefox and Chrome family browsers.

  1. In the Settings/Preferences dialog (Ctrl+Alt+S), select Tools | Web Browsers.

  2. Select the browser in the list and click the Edit button.

    • For Firefox, specify the path to the profiles.ini file and choose the profile to use. For more information, see 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.

Last modified: 14 October 2019