How to use PyCharm with Google compute engine
12,907
Solution 1
The following requires, as James Hirschhorn pointed out, the Professional verison of PyCharm.
- Assign a public IP to the remote machine on GCP.
- Run
gcloud compute config-ssh
to automatically add the VMs of your project to your~/.ssh/config
or manually add the public IP of your VM to it. If you skipped step 1. then you have to rungcloud compute config-ssh
every time you re-start the remote VM, because it always gets a new IP assigned. The~/.ssh/config
gets populated with many entries in the following format:Host the-vm-host-name # use this in PyCharm's Host field HostName 123.456.789.00 # the VM's IP address
- Use the
Host
name of the remote you want to connect in your Deployment configuration in PyCharm - Add a remote interpreter: select the remote server from the drop-down (the one previously created) and point PyCharm to the executable
python
of your Python installation. - Done
Solution 2
My understanding is that you need the Pycharm Ultimate Edition to support remote servers. If you have Ultimate, then you can follow these instructions.
Solution 3
It's fairly easy to accomplish. You need:
-
PyCharm Pro
-
Create and format SSH keys
-
Config your Compute Engine instance with the SSH keys
-
Configure PyCharm
You can follow this tutorial that I wrote.
Author by
ryuzakinho
Updated on June 14, 2022Comments
-
ryuzakinho about 2 years
I have a compute engine instance running on Google cloud platform.
I would like to use the Python interpreter of the compute engine as a remote interpreter with Pycharm. This means that I would be using Pycharm on my local machine and running computations remotely.
Any clue on how to achieve this?
-
Gulzar over 4 yearsHow do you accomplish step 4? or 3 for that matter
-
patzm over 3 yearsok damn it, I will update the post above to answer your question. Comments don't format well.
-
MattiH over 2 yearsThanks, the tutorial was great. I still struggle to actually run the scripts in GCP even if my pycharm says it uses remote python. I probably need to move the files I run somehow to my VM instance on GCP, I guess.
-
gidutz over 2 yearsWhen you set it up correctly alongside the run configuration there should be a deployment set up. Read about how to deploy your code to the remote machine jetbrains.com/help/pycharm/tutorial-deployment-in-product.html
-
MattiH over 2 yearsThanks gidutz. Yes, actually for some reason the directory path in my pycharm configuration had been done incorrectly in the automated setup. I had to go and manually correct the target path. Now it works like a dream. :)