Skip to content

Instantly share code, notes, and snippets.

@rszeto
Last active April 12, 2023 18:29
Show Gist options
  • Save rszeto/d3f9a3478feb89652d9c56a5ce62ef31 to your computer and use it in GitHub Desktop.
Save rszeto/d3f9a3478feb89652d9c56a5ce62ef31 to your computer and use it in GitHub Desktop.
  1. Clone project to local: git clone <project URL>
  2. Create project root on remote: ssh <server> mkdir -p <remote project path>
  3. Create project root and environment on remote
    1. Copy environment.yml to remote
      cd <local project root>
      scp environment.yml <server>:<remote project path>
    2. Create environment on remote
      ssh <server>
      cd <remote project path>
      conda create -p ./env -y
      conda activate ./env
      conda env update -f environment.yml
  4. Open PyCharm, and open the local project folder (File -> Open)
  5. Add Python interpreter
    1. Open Settings (File -> Settings...)
    2. Click Project: -> Python Interpreter
    3. Click gear icon next to -> Add
    4. Click SSH Interpreter
      1. Create new server configuration to remote, then Next
      2. Set Interpreter as the remote path to the interpreter (e.g., /env/bin/python)
      3. Set sync folders between the local and remote project roots (i.e., <local project path> -> <remote project path>)
      4. Click "Finish" at the bottom
      5. Click "Overwrite" in the "Directory Exists" window that pops up
    5. Click "OK" at the bottom
  1. Edit deployment configuration
    1. Open Deployment Configuration (Tools -> Deployment -> Configuration...)
3. Rename the default deployment configuration to the project name
4. Under the "Connection" tab, set the root path to the remote project path
5. Under the "Mappings" tab
	1. Set the local path to the local project path
	2. Set the deployment path to "/"
6. Click "OK" at the bottom
  1. Update Python run template
    1. Click "Add Configuration" in top right
    2. Click Templates -> Python
    3. Add DISPLAY environment variable: DISPLAY=localhost:10.0
    4. Set Python interpreter to the project default
    5. Click "OK" at the bottom
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment