Skip to content
This repository has been archived by the owner on Jun 26, 2018. It is now read-only.

PyCharm debugging

Holger Stitz edited this page Nov 3, 2017 · 1 revision

In order to debug the server using PyCharm you need to do two things:

  1. Prepare environment
  2. Create new remote Python interpreter

Prepare environment

Restart Docker with the debug mixin

./docker-compose-debug up

Restart Docker in the normal-mode to exit the debug-mode:

docker-compose up

Create new remote Python interpreter

  1. Within PyCharm go to Settings -> Project Interpreter -> Cogs symbol -> Add Remote...
  2. Select SSH-Credentials and use the following values:
  • Host: localhost
  • Port: 2222
  • User name: root
  • Password: docker
  • Python interpreter path: /usr/local/bin/python NOTE: this is different from the default!
  1. PyCharm should now be able to connect to the docker container and upload some helper files
  2. Create default path mappings
  3. Select project directory and specify it is located at /phovea
  4. In the end the overview page should state: <Project root> -> /phovea
  5. Gevent compatible Python debugging
  6. Go to Build, Execution, Deployment -> Python Debugger
  7. Check Gevent compatible
  8. Uncheck PyQt compatible
  9. Apply changes -> Close settings dialog

PyCharm Python remote interpreter

PyCharm Python debugger

Create a phovea_server debug launch configuration

  1. Run -> Edit Configurations
  2. In the dialog Plus sign (top-left) -> Python
  • Name: phovea_server
  • Script: \phovea\phovea_server\__main__.py
  • Script parameters: --env=dev api
  • Python interpreter: Remote Python (created above)
  • Working directory: \phovea
  • Uncheck Add content roots to PYTHONPATH and Add source roots to PYTHONPATH
  1. Apply and close the dialog

PyCharm debug launch configuration

Run the server using PyCharm

  1. Start Docker using the debug mixin
  2. Set a breakpoint next to the line number in a Python file
  3. Run -> Debug -> phovea_server
  4. Open the URL in the browser that triggers the breakpoint
  5. Debug the Python in the PyCharm panel