Use VSCode to Remotely Develop Python
Prerequisites
- Install VSCode.
- Install the Remote Development Extension Pack.
- Ensure you have SSH access to the remote machine.
- Python must be installed on the remote machine.
Steps to Set Up Remote Development
Connect to the Remote Machine:
- Open VSCode.
- Press
Ctrl+Shift+P
(orCmd+Shift+P
on macOS) to open the Command Palette. - Type
Remote-SSH: Connect to Host
and select your remote machine.
Install Python Extension:
- Once connected, install the Python extension on the remote machine via VSCode.
Configure the Environment:
- Set up your Python interpreter by selecting it in the bottom-left corner of VSCode.
- Use the following command to ensure your
PYTHONPATH
is set correctly:1
export PYTHONPATH=$PYTHONPATH:$(pwd)
Sync Your Code:
- Use Git or other tools to sync your codebase between your local and remote environments.
Run and Debug:
- Open your Python files in VSCode.
- Set breakpoints and use the built-in debugger to test your code.
Use VSCode to Remotely Develop Python
https://www.hardyhu.cn/2025/01/16/Use-VSCode-to-remotely-develop-Python/