Pycharm Community Edition Remote Interpreter

Posted on  by 



PyCharm 2018.2 (Professional Edition) Build #PY-182.3684.100, built on July 24, 2018 JRE: 1.8.0152-release-1248-b8 amd64 JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o Windows 10 10.0. Edit: Adding a non remote python interpreter to the project fixed the problem, even after switching back to the remote interpreter.

  1. Pycharm Ssh Interpreter
  2. Pycharm Remote Development Ssh
  3. Pycharm Community Edition Remote Interpreter
  1. I also have another project (on the same machine, using same remote interpreter), that seems to work perfectly ok and runs anything on a Python Console. However, I was not able to understand what is the difference between the projects. System info below. PyCharm 2019.3.1 (Professional Edition) Build #PY-193.5662.61, built on December.
  2. Just as a guess: are you using the free community edition of PyCharm? Unfortunately remote interpreters and remote debugging are only supported by the professional edition. You might take a look into the editions comparison on their website. If you are using the pro version, we might have to dig a little deeper.

Introduction

There is a most important thing I want to remind before I start: to use the Python interpreter of remote server requires the professional version of PyCharm. The community version has no way to configure the remote Python interpreter. (If I make a mistake, please feel free to tell me.)

Fortunately, in addition to spending money to buy it, you can apply for a free professional version if you are a student and have a school email address. One application can be valid for one year.

Server

You can go to the following website to apply: https://www.jetbrains.com/pycharm/download/#section=windows

If you want to know how to install PyCharm, maybe you can refer to this article: PyCharm Installation Tutorial, A famous Python IDE

Okay, let's start!

Configure remote interpreter settings

First, I build a new project of the example.

Select File => Settings to open the setting window. Of course you can also use the shortcut key Ctrl + Alt + s to open it.

After opening, select Project: 'YOUR_PROJECT_NAME' => Project Interpreter in the left bar.

Click the gear in the upper right corner and select Add button. The add Python interpreter window pops up:

Select SSH Interpreter.

Select New server configuration, and fill in the connection settings in sequence. After selecting, select Next.

Enter the password of the connection account, and then select Next again.

For the remote Python interpreter, you can use ssh command to connect to it first, and use the following command to confirm where the Python interpreter is.

Usually the path is approximately:

Above this is the path of my Python interpreter.

It is not recommended to preset the location of the synchronization folder, but it is better to create it separately. The method to change the path is to click on the folder icon on the right of step 2 in the figure, and then select the folder on the right of Remote Path again to select the folder you want to synchronize remotely.

Select Finish to end the configuration of the remote interpreter.

Hint

If PyCharm does not feel smooth or a bit stuck during remote synchronization, it may be because its background has been detecting whether to synchronize all files in the current folder. You can go to Tools => Deployment => to turn off Automatic Upload. Maybe it will be smoother.

If there is no manual upload file to the remote synchronization folder under Deployment, you can enter Configuration for configuration.

After configuring in order, there is probably no problem.

Maybe you want to read:

Pycharm
1. This tutorial is intended for UofT ECE361, however, it is general enough for any other interested readers.
2. The purpose of this tutorial is to provide help to those who have problems with VM's screen size or the installed IDE and want to have a full IDE to work with.
3. This workaround is completely optional and does not affect your ability to do the labs, however, it might make it easier.
4. Thanks to Sarhad Salam, he has created a similar guide to setup SSH login for a VM which uses vscode.
Pycharm Community Edition Remote Interpreter
Assume you have installed a VM on the VirtualBox. We first see how we can access the VM terminal within the host machine. Then we will see how to run our python code using PyCharm IDE, which is installed on the host while codes and the interpreter are all located on the VM.

Getting Started

VM Network Configuration

There are possible configurations for the VM within VirtualBox, namely “Bridge” and “NAT” mode. NAT is the simplest way of accessing an external network from a virtual machine. We set the network adaptor mode to NAT and configure Port Forwarding in order to get access to the VM from the host.

Go to the Network and then select NAT in “Attached to” and click on Port Forwarding:

In the following step we forward all queries sent to the port 2229 of the Host to the port 22 of the VM which is the default port for SSH. The port number 2229 can be any arbitrary available port in the host. Add a new entry and enter the number 2229 for Host Port and number 22 for the Guest Port. Leave everything else and click on Ok.

Then start the VM and you are done with VM’s network configuration!

Pycharm Ssh Interpreter

Connect to the VM from the Host (your computer)

Now you are able to open your terminal and connect to the VM from your machine (host). Thus, minimize the VM (you do not have to work with the VM’s actual window anymore!) and continue using SSH.

If you work with Microsoft Windows you have to use putty and then connect to your VM. Look at this instruction to see how you can get started with putty. Please note if you have followed the above instructions then the hostname is localhost, the port is 2229 and the username and password are the same as your VM.

Now open a new terminal (either your Linux/MacOS terminal or putty) and connect to the VM:

Then it prompts for the password, after entering the password you will log into the VM. Now you can open as many terminals as you need and as long as you have made an SSH connection (like fig. 5) then you can think of each of them as a VM terminal. Every command you enter is executed in the VM.

Using PyCharm over SSH Connection

Now we are looking for an IDE that lets us work on files on the remote server and execute them! Thus, download and install PyCharm Professional Edition. If you install community edition, it does not provide you with the feature we are looking for. You can use your university mail to activate the license.

After installation lunch the IDE and select Create new project:

Enter a new name for the project and move forward according to the image below:

Pycharm Remote Development Ssh

According to the image below, enter localhost and ubuntu for the Host and Username fields, respectively. Enter the port number 2229 in the port number field. Then press next.

In the next step you give the path where the python binary is located. This can be the default python path in your system (you can get that using whereis python). However, we have to use the binaries provided within the lab. Similar to when you are using command source /home/ubuntu/lab1/sourceMe. Therefore, enter the path according to the figure below and press finish:

Please note that the path for python virtual environment is not fixed for all labs. As you can see we entered the path which is within lab1 directory. You may be given a completely different virtual environment for each lab and you have to create a new project and reconfigure the above step.
Edition

In the next step, make sure you have selected the Remote interpreter like what you see in the picture below:

Now you have created a project using VM’s python interpreter. Let’s copy files from the VM into the host in order to start editing them. Go to tools, Deployment and then Browse Remote Host:

In the newly opened window, look for home, then ubuntu and lab1. Open the lab1 folder and select both folders track1 and track2 by pressing ctrl button. Then press right-click and select copy according to the image below:

Fig 15: Copy folders from remote server (VM) to your machine (host)

Go to the Project windows in the left side of IDE and past folders inside your project folder:

So now you have lab files from the VM. Before starting to open and work on them, let’s sync your host with the VM so that the changes you are going to make are being synced with the files in the VM. Thus, click on folder project, go to the Deployment and select upload to ubuntu@localhost:2229, like the image below:

Now you are ready to open files, edit and execute them. So let’s open folder track1/module4 and then receiver.py and sender.py. Then run the receiver.py and then do the same for the sender.py:

Now you get results of the execution of each file on the bottom window and it’s like when you are running on two separate terminals inside the VM.

Fig 19: Reciver.py is ruuning and you can see its status on the terminal

Pycharm Community Edition Remote Interpreter

Congratulations! You have successfully edited and executed your files on the remote VM!





Coments are closed