In-depth analysis of PyCharm remote debugging (debug): a comprehensive guide to connecting remote container code and environment

Need to download Pycharm professional version

connection container

  1. Open Tools/Development/Configulation
    Insert image description here
  2. Click the + logo and select SFTP
  3. enter a name

Insert image description here

  1. Enter Connection, click on the three dots behind SSH, and configure the connection.
    Insert image description hereInsert image description here
    Note: The port configured above must be mapped to the port after the ssh port inside the container. The implementation method is to write a port mapping port 22 in the dockerfile. (You must add quotation marks when mapping port 22)
    Insert image description here
  2. After completion, click OK to enter the Mapping directory.
    A big pitfall of pycharm is: remote debugging, which requires downloading the code to the local computer first. That's why here is the configuration of local and remote code paths.
    Insert image description here
  3. At this point, the configuration is complete, then select Tools/Development/Browse Remote Host to see the path in your container on the side.
    Insert image description here
    Insert image description here

Connect to the python environment in the remote container

  1. Go to File | Settings | Project: web_api_source_code | Python Interpreter | Add and select On ssh
    Insert image description here
  2. Fill in the information and click next
    Insert image description here
  3. enter password
    Insert image description here
  4. Start the connection, wait until the connection is completed, and click next
    Insert image description here
  5. Select the environment
    Insert image description here
    and then enter the System Interpreter. In the Sync folders, you need to select your project file. Generally, it will be the default here, but please note that this default is wrong and must be changed.
    Insert image description here
    Insert image description here
  6. After the top-level create is configured, it has successfully connected to the python environment in your container.
    Insert image description here
    [It is not easy to write articles. If you need to forward them, please contact the author!

Guess you like

Origin blog.csdn.net/qq_46170664/article/details/132105987