PyCharm 2020.3 Help

Create and edit run/debug configurations

With the Navigation bar visible (View | Appearance | Navigation Bar), the available run/debug configurations are displayed in the run/debug configuration selector in the Run area:

Choosing PyCharm run/debug configurations

Select Edit Configurations to open the Run/Debug Configuration dialog and create configuration profiles or change the default ones.

Use the toolbar of the Run/Debug Configuration dialog to add, remove, or save configurations.

Create a run/debug configuration

  1. Open the Run/Debug Configuration dialog in one of the following ways:

    • Select Run | Edit Configurations from the main menu.

    • With the Navigation bar visible (View | Appearance | Navigation Bar), choose Edit Configurations from the run/debug configuration selector.

    • Press Alt+Shift+F10, then press 0 or select the configuration from the popup and press F4.

  2. In the Run/Debug Configuration dialog, click Icons general add on the toolbar or press Alt+Insert. The list shows the default run/debug configurations. Select the desired configuration type.

    The fields that appear in the right-hand pane display the default settings for the selected configuration type.

    creating a new run/debug confiugration
  3. For a new run/debug configuration:
    • Specify its name in the Name field. This name will be shown in the list of the available run/debug configurations.

    • Select Allow parallel run to launch a run configuration multiple times in parallel instead of rerunning it. Each runner will start in its own tab of the Run Tool Window or Debug Tool Window.

  4. In the Configuration tab fill in the following options:
    Item Description
    Script path/Module name Click the list to select a type of target to run. Then, in the corresponding field, specify the path to the Python script or the module name to be executed.
    Parameters

    In this field, specify parameters to be passed to the Python script.

    When specifying the script parameters, follow these rules:

    • Use spaces to separate individual script parameters.

    • Script parameters containing spaces should be delimited with double quotes, for example, some" "param or "some param".

    • If script parameter includes double quotes, escape the double quotes with backslashes, for example:

      -s"main.snap_source_dirs=[\"pcomponents/src/main/python\"]" -s"http.cc_port=8189" -s"backdoor.port=9189" -s"main.metadata={\"location\": \"B\", \"language\": \"python\", \"platform\": \"unix\"}"
      .

    In this field you can add a macros to pass various project- or context-specific values when running a run/debug configuration. Click + and select one of the available macros from the list. See Adding macros to run/debug configuration for more details.

    Environment
    Environment variables This field shows the list of environment variables. If the list contains several variables, they are delimited with semicolons.
    By default, the field contains the variable PYTHONUNBUFFERED set to 1. To fill in the list, click the browse button, or press Shift+Enter and specify the desired set of environment variables in the Environment Variables dialog.
    To create a new variable, click the Add button, and type the desired name and value. You might want to populate the list with the variables stored as a series of records in a text file, for example:
    Variable1 = Value1 Variable2 = Value2
    Just copy the list of variables from the text file and click Paste (Paste) in the Environmental Variables dialog. The variables will be added to the table. Click Ok to complete the task. At any time, you can select all variables in the Environment Variables dialog, click Copy Copy, and paste them into a text file.
    Python Interpreter

    Select one of the pre-configured Python interpreters from the list.

    Interpreter options In this field, specify the string to be passed to the interpreter. If necessary, click Expand the field, and type the string in the editor.
    Working directory

    Specify a directory to be used by the running task.

    • When a default run/debug configuration is created by the keyboard shortcut Ctrl+Shift+F10, or by choosing Run from the context menu of a script, the working directory is the one that contains the executable script. This directory may differ from the project directory.

    • When this field is left blank, the bin directory of the PyCharm installation will be used.

    Add content roots to PYTHONPATH Select this checkbox to add all content roots of your project to the environment variable PYTHONPATH;
    Add source roots to PYTHONPATH Select this checkbox to add all source roots of your project to the environment variable PYTHONPATH;
    Execution
    Emulate terminal in output console Enables running your script or module in the output console with the emulated terminal mode. This mode can be helpful for the tasks that cannot be implemented with the standard output console, for example, when your script performs caret return actions (print(i, flush=True , end='\r').
    Note that emulating terminal in the output console differs from running the Terminal that is a separate tool window used for running system shell commands.
    Run with Python console Enables running your script or module with the Python console.
    Redirect input from Enables redirecting data from a text file to standard input. Use this option if your script requires some input and you want to automatically submit the values instead of typing them in the Run console. To enable redirecting, select the checkbox and specify the path to the target text file.
    Docker container settings

    Click the Browse button to open the dialog and specify the following settings:

    Options
    • Publish all ports: Expose all container ports to the host. This corresponds to the option --publish-all.

    • Port bindings: Specify the list of port bindings. Similar to using the -p option with docker run.

    • Volume bindings: Use this field to specify the bindings between the special folders-volumes and the folders of the computer, where the Docker daemon runs. This corresponds to the -v option.
      See Managing data in containers for details.

    • Environment variables: Use this field to specify the list of environment variables and their values. This corresponds to the -e option. Refer to the page ENV (environment variables) for details.

    • Run options: Use this field to specify the docker command-line options.

    Click Icons actions move down to expand the tables. Click Icons general add, Icons general remove, or Icons actions edit to make up the lists.

    Docker Compose
    Commands and options

    You can use the following commands of the Docker Compose Command-Line Interface:

    Commands Supported Options
    up— Builds, creates, starts, and attaches to containers for a service. --build, --abort-on-container-exit, --timeout TIMEOUT, --exit-code-from SERVICE, --scale SERVICE=NUM..., SERVICE...
    run— Runs a one-time command against a service. See the reference docs. --name NAME, --entrypoint CMD, -l, --label KEY=VAL, -u, --user="", --rm, -p, --publish=[], --service-ports, --use-aliases, -v, --volume=[].
    exec— Runs arbitrary commands in your services. --privileged, -u, --user USER, --index=index.
    Command Preview

    You can expand this field to preview the complete command string.

    Example: if you enter the following combination in the Commands and options field:

    up --build exec --user jetbrains

    the preview output should looks as follows:

    docker-compose -f C:\PyCharm-2019.2\Demos\djangodocker-master\docker-compose.yml -f <override configuration file> up --build exec --user jetbrains
  5. In the Before launch section, define whether you want to execute some tools or scripts prior to launching the run/debug configuration.

  6. In the Execution section, you can select a method to run the script (Emulate terminal in output console or Run with Python console). If needed, enable redirecting data from a text file to standard input (Redirect input from).

  7. Specify additional parameters depending on the configuration type. For descriptions of run/debug configuration parameters, refer to the Run/debug configurations dialog section.

  8. Apply the changes and close the dialog.

Edit an existing run/debug configuration

  1. Do one of the following:
    • From the main menu, choose Run | Edit Configurations.

    • With the Navigation Bar visible (View | Appearance | Navigation Bar), choose Edit Configurations from the run/debug configurations selector.

    • Press Alt+Shift+F10, then press 0 to display the Edit Configuration dialog, or select the configuration from the popup and press F4.

  2. In the corresponding run/debug configuration dialog, change parameters as required.

If a project has been created in an earlier version of PyCharm, its run/debug configurations can be lost, when such a project is , added to another project already opened in the same window.

To avoid the loss of run/debug configurations, it is recommended that you open such a project once in the latest version, and only after being added to another project.

Enable the Services tool window

You can manage multiple run/debug configurations in the Services tool window. For example, you can start, pause, and stop several applications, track their status, and examine application-specific details.

  1. From the main menu, select Run | Edit Configurations or use the selector on the toolbar.

    Selecting a run/debug configuration

  2. In the Run/Debug Configurations dialog, select Templates from the list on the left.

  3. In the right-hand pane, expand the Configurations available in Services section.

  4. Click the Add button in the Configurations available in Services section and select the necessary run configuration type.

    You can add or remove multiple configuration types one by one.

    Enabling the Run dashboard

    Note that the tool window will only display the configuration types for which you have created one or more configurations.

    Thus, if you add a configuration type for which no configurations exist in the project, this type will not be displayed in the tool window until you create a configuration of this type.

  5. Apply the changes and close the dialog. The Services tool window with the selected configurations will open.

    Run/Debug configurations in the Services tool window
Last modified: 15 January 2021