Preparations

In Windows, remote Python code redirection and association are supported.

Configuring the Python SDK Interpreter

To meet Python code debugging requirements during application development, a Python code debugging method based on the Python Community Edition plugin is provided. The debugging preparation is as follows. For details about how to configure the Python interpreter, see Python SDK Dependency Settings.

  1. Add the Python SDK.
    1. On the top menu bar, choose File > Project Structure....
    2. In the left pane of the dialog box displayed, choose Platform Settings > SDKs. Then, click + and select Add Python SDK in the displayed dialog box, as shown in Figure 1.
      Figure 1 Configuring the Python SDK
    3. In the Add Python Interpreter dialog box, select a proper Python interpreter and add it. Table 1 shows the available interpreters.
      Figure 2 Adding a Python interpreter
      Table 1 Python interpreter options

      Interpreter

      Description

      Virtualenv Environment

      Integrates the Virtual Environment tool to create an independent virtual environment.

      Conda Environment

      Uses the Python interpreter contained in Anaconda.

      System Interpreter

      Specifies the local interpreter in the system.

      Pipenv Environment

      Pipenv is a tool that provides all the necessary means to create a virtual environment for Python projects.

      Poetry Environment

      Uses the Poetry tool to create a virtual environment based on project dependencies.

      SSH Interpreter

      Specifies a remote interpreter. You can add the Python SDK of a remote device in SSH mode and use the Deployment function to synchronize the files and folders in a specified project to a specified directory on the remote device. For details, see Deployment. (If you select this option, MindStudio remotely runs a project.)

  2. Configure the Python dependency for the project.
    1. On the top menu bar, choose File > Project Structure....
    2. In the left pane of the dialog box displayed, choose Project Settings > Project and select the Python SDK to be added from the SDK drop-down list. Figure 3 shows a configuration example.
    Figure 3 Python dependency configuration

Debugging and Building the Configuration File

  1. On the top menu bar, choose Run > Edit Configurations... or click the run configuration box on the toolbar to access the run configuration page.
    Figure 4 Run configuration box
  2. Click + in the upper left corner, select Python, and add the run and debug configurations of the file.
  3. The configuration options are displayed on the right. Table 2 describes the key configuration parameters. Figure 5 shows a configuration example.
    Click Apply, and then click OK to save the settings and close the debug configuration page.
    Figure 5 Configuration options of the source file
    Table 2 Debug and run parameters

    Parameter

    Description

    Name

    This parameter is user-defined.

    Script path

    Select the path of the Python source file to be debugged.

    Python interpreter

    Use SDK of module: interpreter specified by the project. For details, see Configuring the Python SDK Interpreter.

    Use specified interpreter: local/remote interpreter. You can switch between local and remote interpreters.

    Working directory

    Working directory (defaults to the directory where the Python source file to be debugged is located).