Intellij/Pycharm can't debug Python modules

前端 未结 4 1427
独厮守ぢ
独厮守ぢ 2020-12-30 01:56

I use PyCharm/IntelliJ community editions from a wile to write and debug Python scripts, but now I\'m trying to debug a Python modu

4条回答
  •  暖寄归人
    2020-12-30 02:39

    There is another way to make it work.You can write a python script to run your module.Then just configure PyCharm to run this script.

    import sys
    import os
    import runpy
    path = os.path.dirname(sys.modules[__name__].__file__)
    path = os.path.join(path, '..')
    sys.path.insert(0, path)
    runpy.run_module('', run_name="__main__",alter_sys=True)
    

    Then the debugger works.

提交回复
热议问题