How to set up PyCharm for debugging?

Hello everyone,

I set up my development environment under Ubuntu Linux 18.04 using the documentation:

Now I want to debug into the code with PyCharm. How do I create the run configuration in PyCharm correctly? (using the virtualenv etc.)

Thank you for your help :slight_smile:

1 Like

For anyone trying to get debugging working in PyCharm. Here is my working run configuration for Home Assistant. I followed the guide https://developers.home-assistant.io/docs/en/development_environment.html and then configured PyCharm like this:

5 Likes

Is there any howto, to get this running on Windows with pycharm?

1 Like

I can’t debug :frowning:

I get this error

Traceback (most recent call last):
  File "/home/miguel/.local/share/JetBrains/Toolbox/apps/PyCharm-C/ch-0/231.8109.197/plugins/python-ce/helpers/pydev/pydevd.py", line 1496, in _exec
    pydev_imports.execfile(file, globals, locals)  # execute the script
  File "/home/miguel/.local/share/JetBrains/Toolbox/apps/PyCharm-C/ch-0/231.8109.197/plugins/python-ce/helpers/pydev/_pydev_imps/_pydev_execfile.py", line 18, in execfile
    exec(compile(contents+"\n", file, 'exec'), glob, loc)
  File "/home/miguel/PycharmProjects/core/homeassistant/__main__.py", line 10, in <module>
    from .const import REQUIRED_PYTHON_VER, RESTART_EXIT_CODE, __version__
ImportError: attempted relative import with no known parent package

Use venv/bin/hass for your script path, -c config for your params, and your working dir should just be the root of the project.

Make sure you’ve also already followed the development setup docs. In particular that you’ve run script/setup.

1 Like

Perfect! Thanks you!

1 Like