How can I start debugging in a new console (bash/xterm in ubuntu - outside of the ide)?
How do I tell the pycharm debugger to start xterm (or any other ubuntu terminal emulator which ISN'T the internal pycharm console)?
Why?
1. Because right-to-left languages aren't in sync with the main ubuntu (20.04) which seems to be able to support RTL
2. Because inputing more than simple strings (like using inquirer package, or more complex scenarios) is impossible within the built in console emulator.
Please sign in to leave a comment.
PyCharm debugger only supports the built-in Python console.
So, simply put... PyCharm does not support debugging of python console apps. Makes totally sense.
I may have misunderstood your question. Could you provide more details about your project?
If you develop a console app, you can start debugging your project in PyCharm, then start an external console and send some data to your app - the debugger should stop on the breakpoints.
Say you are building a console tool that requires some fine terminal behavior, such as an ncurses or inquirer packages provide for user choice, or xsel utility output to get the selected text on the terminal. Using the built in console window inside the IDE will be no good, as it intercept input keys/mouse and has output issues too with other languages which aren't ANSI/Left-to-right. In such conditions, you might want to start an external terminal emulator (XTERM for example on ubuntu) and let it run the python app. A modern debugger like PyCharm can probably do it, as it supports multiprocessing (to some extent) but how to setup the debugging configuration to start XTERM in PyCharm I still don't know...
So, you must start the app from the external terminal? In this case, there are two options for debugging:
1. Using "Attach to process" functionality https://www.jetbrains.com/help/pycharm/attaching-to-local-process.html
2. Using Python remote debug server: https://www.jetbrains.com/help/pycharm/remote-debugging-with-product.html#remote-debug-config
The first option means you can start your script from e.g. XTERM, and attach PyCharm debugger to the python process
The second option suggests that you add some additional code to your python script that initiates a connection with the debugger.
Thanks for your answer! Let me just comment on those two options:
1. Attach to process may work, it needs some extra configurations to work... Couldn't find any clear example to such configuration online. So it might work. Might not...
2. Remote debugging would probably not be the best way, as it is intended more for remote servers, and require extra code to be entered onto the debugged code + it might not be very useful when debugging multithreaded apps... from my experience with remote servers you need to disallow servers such as Apache Tomcat from starting more then one thread and it might not be suitable for any script.
I think it would be great if JetBrains would allow us choose the terminal emulator, and not force us to use the built in one (as useful as it may be for some applications) as it is it's a real pain, and you have to write extra code to support the built in console just to make the code debuggable (or just skip debugging in favour of logging...).
I can suggest to submit a feature request to https://youtrack.jetbrains.com/issues/py , as at the moment, as I mentioned, PyCharm debugger can only work with the built-in terminal.
Please try attaching to a process option, it shouldn't require additional configuration.