Skip to main content

Connecting PyCharm to the Development Environment

PyCharm version used in the following example: PyCharm 2018.3 (Professional Edition) The AIStation development environment SSH service is running normally. The connection information below is for format reference only; please replace it with the actual IP, port, and temporary password displayed by the platform, for example: IP 10.x.x.x, port <SSH_PORT>, password <TEMP_PASSWORD>.

1. PyCharm Configuration

Open PyCharm, select Tools -> Deployment -> Configuration… imageClick the plus sign in the top-left corner and select SFTP image imageEnter the configuration name: imageIn the Connection panel on the right, set Type to SFTP. Enter the IP and port obtained in Step 2 for Host and Port, respectively. Enter the password obtained in Step 2 in the Password field. imageClick the "Test Connection" button to test the connection. A success message will be displayed. imageThe connection configuration is now complete.

2. Connect to the Development Environment via SSH

Open PyCharm, select View -> Tool Windows -> Terminal. imageA command-line window will appear in PyCharm. imageSelect Tools -> Start SSH session… imageIn the pop-up window, select the configuration created earlier: imageCheck the command-line window; you have successfully connected to the container hosting the AIStation development environment. image

3. Configure Remote Debug

Open PyCharm, select Tools -> Deployment -> Configuration…imageSelect the Server configured earlier as 'DevelopmentEnv'. Click Mappings.image
Click the "folder" icon to select the local and remote paths respectively.image
Set Local path to the path of the local code. Set Deployment path to the path of the code within the AIStation development environment. As shown in the figure. Right-click the corresponding code file or project folder in PyCharm, and select Deployment -> Upload to…
image
In the pop-up dialog, select the previously created Server configuration "DevelopmentEnv".
image
The following prompt indicates that the local code files have been uploaded to the corresponding directory in the AIStation development environment. image View the development environment: image

4. Configure Debug Packages in the Development Environment

The Debug package can be found on the operating system where PyCharm is installed.
Corresponding path in MacOS:
/Applications/PyCharm.app/Contents/debug-eggs/pycharm-debug-py3k.egg
/Applications/PyCharm.app/Contents/debug-eggs/pycharm-debug.egg
Corresponding path in Windows:
In the PyCharm installation directory \debug-eggs\ pycharm-debug-py3k.egg
In the PyCharm installation directory \debug-eggs\ pycharm-debug.egg
pycharm-debug.egg and pycharm-debug-py3k.egg correspond to local Python interpreters for Python 2 and Python 3, respectively.
For example, to debug a Python 3 program, copy pycharm-debug-py3k.egg to the development environment (you can upload it using the scp command or tools like Xftp or FileZilla).
scp -P SSH_PORT pycharm-debug-py3k.egg root@SSH_HOST:/home/USERNAME/DevelopmentEnv image
In the development environment, run easy_install pycharm-debug-py3k.egg to install it.
Run pip install pydevd

5. Configure Remote Debug

Click Run -> Edit Configurations...imageIn the dialog box that appears, click the "+" icon in the upper-left corner. Select "Python Remote Debug". imageName this configuration DevelopymentDbg. Enter your local IP address in the Local host name field, and enter an available local port in the port field. imageCopy the two lines of code in the red box and add them to your program. imageClick the dropdown menu shown in the red box and select the DevelopmentDbg configuration you just created. Then click the green debug icon button. imageWhen the console displays "Waiting for process connection... Connected to pydev debugger", enter the development environment to proceed. imageEnter the development environment and run python3 uncompress.py. imagePyCharm displays the following, with the program paused at the first breakpoint, ready for remote debugging. image