{"id":16936767,"url":"https://github.com/opcode81/remote-python-intellij","last_synced_at":"2025-04-11T19:08:02.967Z","repository":{"id":146886678,"uuid":"169738614","full_name":"opcode81/remote-python-intellij","owner":"opcode81","description":"Instructions on setting up remote Python interpreters in IntelliJ/PyCharm","archived":false,"fork":false,"pushed_at":"2023-02-21T10:49:17.000Z","size":12,"stargazers_count":5,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-25T14:51:23.666Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/opcode81.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-02-08T13:24:55.000Z","updated_at":"2023-06-13T10:39:48.000Z","dependencies_parsed_at":null,"dependency_job_id":"bdc18bc8-7236-4b88-94cf-158a1e001a1b","html_url":"https://github.com/opcode81/remote-python-intellij","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/opcode81%2Fremote-python-intellij","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/opcode81%2Fremote-python-intellij/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/opcode81%2Fremote-python-intellij/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/opcode81%2Fremote-python-intellij/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/opcode81","download_url":"https://codeload.github.com/opcode81/remote-python-intellij/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248465316,"owners_count":21108244,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-13T20:57:51.116Z","updated_at":"2025-04-11T19:08:02.960Z","avatar_url":"https://github.com/opcode81.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Remote Python Interpreter Configuration in IntelliJ/PyCharm\n\nThis document describes how to set up a remote Python interpreter in IntelliJ/PyCharm.\nThe use of remote interpreters is particularly useful in order to share computational resources such as GPUs or in order to execute jobs in remote clusters which provide access to data that is locally unavailable.\n\n## Configure SSH Access with X11 Forwarding to Remote Machine\n\nConfigure an SSH connection to the remote machine using a key for authentication (no password).\nMake sure X11 forwarding works for the connection, i.e. you are able to open graphical applications on the remote machine.\n\nTo support X11 on platforms that do not natively use it:\n* On Windows, establish a remote connection using an integrated solution such as [MobaXterm](https://mobaxterm.mobatek.net/download.html) or a stand-alone X-server such as [XMing](https://sourceforge.net/projects/xming/).\n* On MacOS, install and run [XQuartz](https://www.xquartz.org/) and use the XQuartz terminal to initiate the SSH session (with \"-XY\" argument).\n\n## Configure Remote Interpreter in IntelliJ\n\n- Under File/Project Structure, select \"SDKs\"\n- Click \"+\" to add a new interpreter and select \"Python SDK\"\n- Select \"SSH Interpreter\"\n- Enter host, port and user name and click \"Next\"\n- Enter location of python interpreter on remote machine (ideally a virtualenv, e.g. `/usr/local/share/virtualenvs/odmalg/bin/python`)\n- Deployment Configuration (\"Sync Folders\")\n  - Choose a path for the storage of project files on the remote server, which all project files will be synchronised to, e.g. `/home/myuser/myproject-remote`\n  - (The previous step will have created a new deployment, which will appear under Tools/Deployment.)\n\n## Running Python Scripts Remotely \n\nTo run a script remotely, simply choose the remote interpreter we configured above.\n\nIn order to make sure that interactive plots and other things that pop up windows will be transferred to your local machine, make sure that \n* you have an X11 server running on your local machine (see above) \n* you have an open SSH connection to the remote machine with X11 forwarding enabled. Note down the value of the DISPLAY environment variable on the remote machine. \n\nThen, make sure IntelliJ is correctly configured:\n* To make sure the the display is correctly addressed, from IntelliJ/PyCharm, *either*\n    * set, in each run configuration, the environment variable DISPLAY to the value that we retrieved earlier \n    * configure the value of the DISPLAY environment variable in the Settings/\"Python Console\" and configure each run configuration to \"Run with Python Console\"\n    * configure the Python console to use the desired rendering backend by configuring the Python Console starting script, e.g. QT as follows\n      \n            import os\n            import sys; print('Python %s on %s, running in %s' % (sys.version, sys.platform, os.getcwd()))\n            print(f\"DISPLAY: {os.getenv('DISPLAY')}\")\n            sys.path.extend([WORKING_DIR_AND_PYTHON_PATHS])\n            %load_ext autoreload\n            %autoreload 2\n            %matplotlib qt5\n\n* To prevent plot windows to be captured by IntellIJ (which does not work), under Settings/Tools/Python Scientific, uncheck \"Show plots in tool window\".\n\n## Reusing the Python Interpreter for Another Project\n\nThe interpreter can be reused (it is global) in a new IntelliJ/PyCharm project, but the deployment needs to configured and activated.\n\n### Configure the Deployment in IntelliJ\n\n- Under Tools/Deployment/Configuration, adjust the configuration of the pre-existing deployment for the server (which should be present as a result of the SSH interpreter creation), making sure it is the selected deployment (use the \"tick\" button). NOTE: Creating a totally new deployment (even if it contains the exact same settings) does *not* work in our experience.\n- The deployment should contain the right type (\"SFTP\"), host name, and port and authentication information.\n- Click \"Test connection\" to verify that the connection can be established.\n- Under the \"Mapping\" tab, map the project root folder to a remote folder. Note that the folder specified is relative to the \"Root path\" under \"Connection\" (if it does not start with \"/\").\n- Apply the changed configuration.\n- Under Tools/Deployment, enable \"Automatic Upload\" (such that the menu item is ticked thereafter)\n\n## Triggering Deployment\n\nIf \"Automatic Upload\" is enabled under Tools/Deployment, deployments should be triggered automatically, but it is sometimes necessary to manually initiate deployment via the project context menu: Right click project title the select Deployment/\"Upload to ...\".\n\nAlso, if you use git to switch between states outside of IntelliJ and thus externally modify files, the deployment should configured to act on externally modified files as well: Under Tools/Deployment/Options, uncheck \"Skip external changes\".\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopcode81%2Fremote-python-intellij","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fopcode81%2Fremote-python-intellij","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopcode81%2Fremote-python-intellij/lists"}