I have just started using pycharm with qgis but could not connect both of them. Pycharm always stays in a state of "waiting for connection". Most the tutorials available points to the windows but I am using ubuntu so could not find way to debug qgis code on pycharm. Here is my pycharm code:

from shapely.geometry import *
from shapely.wkt import loads

import sys

import pydevd

pydevd.settrace('localhost', port=53100, stdoutToServer=True, stderrToServer=True)

class Loader:

    def __init__(self, iface):

        """Initialize using the qgis.utils.iface
        object passed from the console.

        self.iface = iface

I have enabled breakpoints in the pycharm and also added the pycharm-debug.egg in the pythonpath does anybody how configure it from qgis on ubuntu?

pycharm is always in:

Starting debug server at port 53100
Use the following code to connect to the debugger:
import pydevd
pydevd.settrace('localhost', port=53100, stdoutToServer=True, stderrToServer=True)
Waiting for process connection...

When I run this script on the top from qgis nothing happens, the breakpoint does not get called.

  • Do you want QGIS classes to be recognized by Pycharm?
    – wondim
    Jul 30 '18 at 3:22

On Arch Linux (but it should work on Ubuntu too), I use this python script that at the loading of QGIS checks if anyone is listening on port 53100. If so, it tries to import pydevd from the pycharm's directory and tries to connect to the remote debugger.

import psutil

def is_listening_local(port=53100):
    """Return True if someone is listening on the port"""

    els = psutil.net_connections()
    for el in els:
        if el.laddr.port == port:
            return True
        return False

if is_listening_local():
        import sys
        # Add the pydevd directory to PYTHONPATH

        import pydevd
        # Connect to the remote debugger
            'localhost', port=53100, stdoutToServer=True, stderrToServer=True,
    except Exception:

My complete configuration is here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.