Setting up a remote interpreter on PyCharm is awfully unintuitive. I've pared it down to what I think is the minimal number of steps, and leaves the fewest number of deployment configurations and Python interpreters lying around. This is designed for my specific configuration (specifically PyTorch); adapt as needed.
- (Optional) Add virtual environment path to excluded files
- From Welcome Page, go to Configure > Settings > Build, Execution, Deployment > Deployment > Options
- Add virtualenv path. For example, if you always have the project's virtualenv in
.env
, add ";.env" to the "Exclude items by name" field
- Create new project
- From Welcome Page, go to "Create New Project"
- Set local project location
- Expand "Project Interpreter", choose "Previously configured interpreter", and configure the interpeter
- Click the "..." next to the "Interpreter" field
- Choose "SSH Interpreter" in the left-hand menu
- Under "New server configuration", enter the Host, Port, and Username. Then, click "Next"
- Set either the Password or the Key pair information, then click "Next"
- Select the interpreter on the remote server (the
python
binary). Then, click "Finish" 4. In the "Remote project location" field, enter the path to your existing Python project 5. Click "Create"
- Update the deployment configuration
- Go to Tools > Deployment > Configuration...
- Rename the deployment server to match the current project
- In the left-hand menu, right-click the deployment server name and choose "Rename"
- Enter the project name, and then click "OK"
- Make the remote host window open at the remote project root
- Under the "Connection" tab, set "Root path" to the remote project root
- Under the "Mappings" tab, set "Deployment path" to "/"
- Click "OK"
- Exclude unnecessary files and directories
- Open the "Remote Host" panel on the right
- Navigate to the project root on the remote server
- Exclude folders/files to keep unsynced by right-clicking them and choosing "Exclude path"
- Download remote files to local project
- In the "Remote Host" panel on the right, right-click the project root and select "Sync With Local..."
- Click the "Synchronize All" button on the top
- Edit default Run/Debug configuration
- In the top menu, go to Run > Edit Configurations...
- In the left panel, go to Templates > Python
- Set environment variables
- Set
DISPLAY=localhost:10.0
- (Optional) Exclude system environment variables
- Set
can I make a connection of the environment in the server with pycharm remotely?
if yes, please show the way...
Thanks in advance.