Opening remote project in PyCharm
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):
- Mount the home folder on my local machine ( I use SFTP Drive on windows, under Linux use sshfs).
- Open the project from the mounted drive in PyCharm
- Go to Settings -> Project -> Project Interpreter and select the gear next to the Project Interpreter drop down. From there pick "Add Remote".
- 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:
And when you load your project files to Pycharm you need to add remote interpreter which is present on your server:
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.
- Open PyCharm
- Create a New Project and select Pure Python
- Fill the Location and Remote project location, which may be new or existing.
- Select the ellipsis next to Interpreter under Previously configured interpreter
- Select SSH Interpreter and create New server connection
- Create the project
- Press Ctrl + Alt + S to open Settings
- Select Deployment under Build, Execution, Deployment
- Select Python Interpreter under Project:...
- Close Settings with OK, or Apply
- Use PUTTY or some other app to verify the project now exists on the remote system
- Right click the project and select Deployment for deployment options
Note
- This will likely require being connected to the corporate network through a VPN.
Related videos on Youtube
kbrk
Updated on January 25, 2022Comments
-
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 about 4 yearsWhen run a project on this setup, will my server resources (CPU, GPU, memory, etc.) be used?
-
Skusku about 4 yearsThe 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 about 3 yearsI found that
Sync with Deployed to...
also works fine (without need for a local mount), when the directory mappings are correctly set for the configuredRemote Host
.