# Setting up PyCharm project with remote interpreter 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. ## Configuring default project (only do after installing PyCharm for the first time): 1. (Optional) Add virtual environment path to excluded files 1. From Welcome Page, go to Configure > Settings > Build, Execution, Deployment > Options 2. Add virtualenv path. For example, if you always have the project's virtualenv in `.env`, add ";.env" to the "Exclude items by name" field ## Configuring a new project 1. Create new project 1. From Welcome Page, go to "Create New Project" 2. Set local project location 3. Expand "Project Interpreter", choose "Existing interpreter", and configure the interpreter 1. Click the "..." next to the "Interpreter" field 2. Choose "SSH Interpreter" in the left-hand menu 3. Under "New server configuration", enter the Host, Port, and Username. Then, click "Next" 4. Set either the Password or the Key pair information, then click "Next" 5. 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" 2. Rename the deployment server to match the current project 1. Go to Tools > Deployment > Configuration... 2. In the left-hand menu, right-click the deployment server name and choose "Rename" 3. Enter the project name, and then click "OK" 3. Click "OK" 3. Exclude unnecessary files and directories 1. Open the "Remote Host" panel on the right 2. Navigate to the project root on the remote server 3. Exclude folders/files to keep unsynced by right-clicking them and choosing "Exclude path" 4. Download remote files to local project 1. In the "Remote Host" panel on the right, right-click the project root and select "Sync With Local..." 2. Click the "Synchronize All" button on the top 5. Edit default Run/Debug configuration 1. In the top menu, go to Run > Edit Configurations... 2. In the left panel, go to Defaults > Python 3. Copy the following environment variables from the remote bash environment: 1. `PYTHONPATH` (value from remote environment) 2. `DISPLAY` (localhost:10.0) 3. `LD_LIBRARY_PATH` (value from remote environment) 4. `LD_PRELOAD` (value from remote environment)