Opening remote project in PyCharm

41,954

Solution 1

The way I access the projects on my raspberry pi using PyCharm is the following (This expects you to be using PyCharm Pro, supporting SSH connections):

  1. Mount the home folder on my local machine ( I use SFTP Drive on windows, under Linux use sshfs).
  2. Open the project from the mounted drive in PyCharm
  3. Go to Settings -> Project -> Project Interpreter and select the gear next to the Project Interpreter drop down. From there pick "Add Remote".
  4. Configure the remote interpreter you want to use.

If the PyCharm project was already created on the server, I guess your run configuration should be in order and running it should work out of the box.

If you created the PyCharm project on your local machine:

  • If you have no run configuration yet, go to the file you want to run and do right-click -> Run yourfilename.py or simply hit Shift-F10
  • The remote interpreter will complain about non existent files. Go to the dropdown in the top right corner, click it and select 'Edit Configurations'
  • Change the script path and working directory to the actual remote directories. Remember, this is what your interpreter sees, and your interpreter is on your remote machine.

Hope this helps!

Solution 2

To update on excellent @Skusku answer given here: https://stackoverflow.com/a/47614111/2119941

After mounting remote folder with SFTP Drive if Pycharm project browser doesn't recognize remote drive just copy-paste it in location bar on top and allow Pycharm to load it:

enter image description here

And when you load your project files to Pycharm you need to add remote interpreter which is present on your server:

enter image description here

In following screens just add host, credentials and than path to python in virtual env or whatever python is running your server project files.

Solution 3

  • The following will configure PyCharm Professional 2021.3.1 on Windows 10 to run a project on a remote Linux server. It's likely the configuration will be similar for PyCharm on macOS.
  1. Open PyCharm
  2. Create a New Project and select Pure Python
  3. Fill the Location and Remote project location, which may be new or existing.
  4. Select the ellipsis next to Interpreter under Previously configured interpreter
  5. Select SSH Interpreter and create New server connection
    • Supply your credentials
    • The default Interpreter will be /usr/bin/python, but an alternate location may be provided, for example /home/.../anaconda3/bin/python3.9
      • enter image description here
    • enter image description here
  6. Create the project
  7. Press Ctrl + Alt + S to open Settings
    1. Select Deployment under Build, Execution, Deployment
      • Check Connection and Test Connection
        • enter image description here
      • Check Mappings to verify Local path and Deployment path
        • enter image description here
    2. Select Python Interpreter under Project:...
      • Verify the remote interpreter is selected for the project.
        • As long as this is the case, the code will run relative to the remote system.
      • enter image description here
    3. Close Settings with OK, or Apply
  8. Use PUTTY or some other app to verify the project now exists on the remote system
    • enter image description here
  9. Right click the project and select Deployment for deployment options
    • enter image description here

Note

  • This will likely require being connected to the corporate network through a VPN.
Share:
41,954

Related videos on Youtube

kbrk
Author by

kbrk

Updated on January 25, 2022

Comments

  • kbrk
    kbrk over 2 years

    I'm working on a project that is located in a remote server. Can I open it in PyCharm from my local machine ? I couldn't find the way.

  • Celso França
    Celso França about 4 years
    When run a project on this setup, will my server resources (CPU, GPU, memory, etc.) be used?
  • Skusku
    Skusku about 4 years
    The last line gives it away: "...and your interpreter is on your remote machine.", so yes, this will run the interpreter on your server, using your server's resources. In fact, I originally used this to work remotely on my machine-learning-rig.
  • phi
    phi about 3 years
    I found that Sync with Deployed to... also works fine (without need for a local mount), when the directory mappings are correctly set for the configured Remote Host.