https://stackoverflow.com/questions/48520524/how-to-debug-code-running-from-terminal-in-pycharm

2가지 방법이 있다. 

[1번 방법] : 위 링크의 1번째 나오는 방법

I don't know anyway to do this through the terminal, but the way I currently do it is:

  1. Run > Edit Configurations > Add new configuration (the green + button)
  2. Choose Python
  3. Fill out Script path, Parameters, and other configuration fields.
  4. Debug the newly added configuration. (Run > Debug...)

With the right configuration the result should be the same as running the script in a terminal.

I find the above process a little tedious. A PEP 553 breakpoint() might be nicer. It requires Python 3.7 and is not implemented yet. See the related issue.

 

[2번 방법] : 위 링크의 2번째 나오는 방법. 아래설명에서처럼 Tools -> Python or Debug Console로 IDE밑에 터미널이 나오면, 아래 그림에서처럼 Attach Debugger 버튼 누르고 breakpoint 건다. 그 후 '%run main.py' 이런 식으로 실행시키면 breakpoint에 디버깅이 걸린다. 
ex) command window에서 'python code/__init__.py --img1 images/aligned_images/suji1_01.png --img2 images/aligned_images/suji2_01.png --output output3.mp4' 라고 실행했다면, 
'%run code/__init__.py --img1 images/aligned_images/suji1_01.png --img2 images/aligned_images/suji2_01.png --output output3.mp4'라고 IDE 밑 터미널 창에 입력해준다. 

 

There is a way using python console.

To run it: Tools -> python console .. or you can find it at the bottom of the IDE.

Then press on 'Attach debugger' line in the following picture: 

Add a breakpoint in your code and then pass the file name to the cosole, like: %run my_file.py

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 
Posted by uniqueone
,