HOW TO use Pycharm to debug python script?

后端 未结 4 1760
不思量自难忘°
不思量自难忘° 2020-12-15 18:14

I\'m trying to use pycharm. I can write code and run it. However, I do not know how to to debug the code. When I click the debug button, I get something similar to the belo

相关标签:
4条回答
  • 2020-12-15 18:46

    Simply from the context menu by clicking on a needed tab, link https://www.jetbrains.com/help/pycharm/starting-the-debugger-session.html

    It will launch debug session in the background, like

    /usr/local/bin/python3.7 "/Applications/PyCharm CE.app/Contents/helpers/pydev/pydevd.py" --cmd-line --multiproc --qt-support=auto --client 127.0.0.1 --port 56411 --file /Users/proskuryakovivan/code/audio/test.py
    
    0 讨论(0)
  • 2020-12-15 18:57

    I'd like to illustrate how to set parameters, as it took me a while to do this right:

    Find the drop-down menu next to the "Run" button:
    enter image description here

    Choose the file you want to configure, then click "Edit Configurations":
    enter image description here

    Add script parameters:
    enter image description here

    0 讨论(0)
  • 2020-12-15 18:57

    I had similar problem in the past when trying to debug with pycharm. The solution was to start the debuging anywhere (first break point) in the file containing the following code:

    def main():
        <your code>
    
    if __name__ == "__main__":
        main()
    
    0 讨论(0)
  • 2020-12-15 19:06

    Take a look at Run -> Edit Configuration dialog where you should click on Add New Configuration ([+] icon at the left top corner). Then you need to choose project type (probably Python in your case), specify your script (.py) file, parameters, Python interpreter to use etc. Once configuration is selected, you should be able to just run your application in debugger.

    Refer to Debugging section in on-line help for more information.

    HelloWorld code:

    def main():
        print "Hello World"
    
    if __name__ == "__main__":
        main()
    
    0 讨论(0)
提交回复
热议问题