PyCharm docker debugging error

SEE EDITS

I'm trying to get the latest version of PyCharm to successfully debug Django running inside Docker. However I'm having trouble setting up the remote python interpreter and I get an error as soon as I try to start the debugger.

Can't run remote python interpreter: com.github.dockerjava.api.exception.InternalServerErrorException: {"message":"the working directory 'C:/Program Files (x86)/JetBrains/PyCharm 171.2613.10/jre64/jre/bin' is invalid, it needs to be an absolute path"}

The path, in my eyes looks pretty absolute, so I'm guessing its something else. I'm not even sure who or what is causing the error. The docker container (because of the JSON response) or PyCharm.

Running

  • PyCharm 2017.1
  • Docker for Windows (docker version 1.13.0)
  • Any thought of what I might be missing/having problem with?

    Edit

    Forgot to include my settings from PyCharm on how I set up the remote interpreter.

    在这里输入图像描述

    I get no errors with the above settings

    Edit 2

    It looked like the "Django project root" had accidentally been set to the incorrect path above. So that is fixed. My problem now is that when I run the Run/Debug Configuration it tries to start the server again, which is already running inside the docker container. Is there no way to attach to the already running python process?

    Edit 3

    I've now managed to get a "success" message when starting the debugger (PyCharms Python Remote Debugger) and starting the server after. However I seems like the debugger stops listening after 1 second (or less). My theory is that the debugger looses connection after it has passed the pydevd.settrace() function call. I have placed the following code (of the top of my head) at the bottom of manage.py :

    sys.path.append('pycharm-debug.egg')
    import pydevd
    pydevd.settrace('192.168.1.100', port=21000)
    

    What am I missing?

    EDIT 4

    After investigating further I now seem to successfully connect the debugger on server startup. However, if the pydevd.settrace(....) function call is present the server never actually starts. The startup seems to freeze/stop on python manage.py runserver 0.0.0.0:8000 . As soon as I remove the settrace line. The server starts without issue. Any ideas?

    I also get this message when the server is starting: warning: Debugger speedups using cython not found. Run '"/usr/local/bin/python" "/usr/local/lib/python3.5/site-packages/setup_cython.py" build_ext --inplace' to build. warning: Debugger speedups using cython not found. Run '"/usr/local/bin/python" "/usr/local/lib/python3.5/site-packages/setup_cython.py" build_ext --inplace' to build.

    The problem is that I can't run the command listed in the message because the file setup_cython doesn't exist.


    You're right! It really don't start the runserver process, but I believe it's not because isn't working, but because it is.

    See, when you successfully connected the pydevd settrace with the debugger server you had to configure on PyCharm it already worked, at least it worked for me.

    I believe the reason runserver isn't working is because the warning created by the missing cython is stopping the debugger, the only thing you have to do is tell it to keep running and jump that warning clicking on the green right-pointing arrow to do so.

    远程调试器停止远程调试器正在运行

    PS.

    I'm debugging a django application running on docker (docker-machine), the host IP, in that case is 192.168.99.1

    #!/usr/bin/env python
    import os
    import sys
    
    if __name__ == "__main__":
        os.environ.setdefault("DJANGO_SETTINGS_MODULE", "helpdesk.settings")
    
        from django.core.management import execute_from_command_line
    
        sys.path.append('pycharm-debug.egg')
        import pydevd
        pydevd.settrace('192.168.99.1', port=3000, stdoutToServer=True, stderrToServer=True)
    
        execute_from_command_line(sys.argv)
    

    pycharm远程调试器配置

    Hope I helped!

    链接地址: http://www.djcxy.com/p/44954.html

    上一篇: PyCharm:如何正确连接到本地进程以进行调试

    下一篇: PyCharm docker调试错误